2015-02-19 09:32:02 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.marathon;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options.services.marathon = {
|
|
|
|
enable = mkOption {
|
2015-06-15 17:10:26 +01:00
|
|
|
type = types.bool;
|
2015-05-16 19:48:13 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable the marathon mesos framework.
|
|
|
|
'';
|
2015-02-19 09:32:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
master = mkOption {
|
|
|
|
type = types.str;
|
2015-05-16 19:48:13 +01:00
|
|
|
default = "zk://${concatStringsSep "," cfg.zookeeperHosts}/mesos";
|
|
|
|
example = "zk://1.2.3.4:2181,2.3.4.5:2181,3.4.5.6:2181/mesos";
|
|
|
|
description = ''
|
|
|
|
Mesos master address. See <link xlink:href="https://mesosphere.github.io/marathon/docs/"/> for details.
|
|
|
|
'';
|
2015-02-19 09:32:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
zookeeperHosts = mkOption {
|
2015-05-16 19:48:13 +01:00
|
|
|
type = types.listOf types.str;
|
2015-02-19 09:32:02 +00:00
|
|
|
default = [ "localhost:2181" ];
|
2015-05-16 19:48:13 +01:00
|
|
|
example = [ "1.2.3.4:2181" "2.3.4.5:2181" "3.4.5.6:2181" ];
|
|
|
|
description = ''
|
|
|
|
ZooKeeper hosts' addresses.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-05-25 10:31:57 +01:00
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "marathon";
|
|
|
|
example = "root";
|
|
|
|
description = ''
|
|
|
|
The user that the Marathon framework will be launched as. If the user doesn't exist it will be created.
|
|
|
|
If you want to run apps that require root access or you want to launch apps using arbitrary users, that
|
|
|
|
is using the `--mesos_user` flag then you need to change this to `root`.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
httpPort = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8080;
|
|
|
|
description = ''
|
|
|
|
Marathon listening port for HTTP connections.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-05-16 19:48:13 +01:00
|
|
|
extraCmdLineOptions = mkOption {
|
2015-02-19 09:32:02 +00:00
|
|
|
type = types.listOf types.str;
|
2015-05-16 19:48:13 +01:00
|
|
|
default = [ ];
|
|
|
|
example = [ "--https_port=8443" "--zk_timeout=10000" "--marathon_store_timeout=2000" ];
|
|
|
|
description = ''
|
|
|
|
Extra command line options to pass to Marathon.
|
|
|
|
See <link xlink:href="https://mesosphere.github.io/marathon/docs/command-line-flags.html"/> for all possible flags.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
environment = mkOption {
|
|
|
|
default = { };
|
|
|
|
type = types.attrs;
|
|
|
|
example = { JAVA_OPTS = "-Xmx512m"; MESOSPHERE_HTTP_CREDENTIALS = "username:password"; };
|
|
|
|
description = ''
|
|
|
|
Environment variables passed to Marathon.
|
|
|
|
'';
|
2015-02-19 09:32:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.marathon = {
|
|
|
|
description = "Marathon Service";
|
2015-05-16 19:48:13 +01:00
|
|
|
environment = cfg.environment;
|
2015-02-19 09:32:02 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-09-10 19:20:00 +01:00
|
|
|
after = [ "network.target" "zookeeper.service" "mesos-master.service" "mesos-slave.service" ];
|
2015-02-19 09:32:02 +00:00
|
|
|
|
|
|
|
serviceConfig = {
|
2015-05-16 19:48:13 +01:00
|
|
|
ExecStart = "${pkgs.marathon}/bin/marathon --master ${cfg.master} --zk zk://${concatStringsSep "," cfg.zookeeperHosts}/marathon --http_port ${toString cfg.httpPort} ${concatStringsSep " " cfg.extraCmdLineOptions}";
|
2015-05-25 10:31:57 +01:00
|
|
|
User = cfg.user;
|
2015-05-16 19:48:13 +01:00
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "2";
|
2015-02-19 09:32:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-10-12 21:25:28 +01:00
|
|
|
users.users.${cfg.user}.isSystemUser = true;
|
2015-02-19 09:32:02 +00:00
|
|
|
};
|
|
|
|
}
|