nixos/rabbitmq: fix module
This commit is contained in:
parent
4631ea8ed9
commit
6e7d708bcc
1 changed files with 20 additions and 12 deletions
|
@ -31,6 +31,15 @@ in {
|
|||
<literal>guest</literal> by default, so you should delete
|
||||
this user if you intend to allow external access.
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
default = 5672;
|
||||
description = ''
|
||||
Port on which RabbitMQ will listen for AMQP connections.
|
||||
'';
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
|
@ -77,6 +86,7 @@ in {
|
|||
users.extraUsers.rabbitmq = {
|
||||
description = "RabbitMQ server user";
|
||||
home = "${cfg.dataDir}";
|
||||
createHome = true;
|
||||
group = "rabbitmq";
|
||||
uid = config.ids.uids.rabbitmq;
|
||||
};
|
||||
|
@ -87,14 +97,16 @@ in {
|
|||
description = "RabbitMQ Server";
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-interfaces.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
path = [ pkgs.rabbitmq_server ];
|
||||
path = [ pkgs.rabbitmq_server pkgs.procps ];
|
||||
|
||||
environment = {
|
||||
RABBITMQ_MNESIA_BASE = "${cfg.dataDir}/mnesia";
|
||||
RABBITMQ_NODE_IP_ADDRESS = cfg.listenAddress;
|
||||
RABBITMQ_NODE_PORT = toString cfg.port;
|
||||
RABBITMQ_SERVER_START_ARGS = "-rabbit error_logger tty -rabbit sasl_error_logger false";
|
||||
RABBITMQ_PID_FILE = "${cfg.dataDir}/pid";
|
||||
SYS_PREFIX = "";
|
||||
RABBITMQ_ENABLED_PLUGINS_FILE = pkgs.writeText "enabled_plugins" ''
|
||||
[ ${concatStringsSep "," cfg.plugins} ].
|
||||
|
@ -103,26 +115,22 @@ in {
|
|||
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.rabbitmq_server}/sbin/rabbitmq-server";
|
||||
ExecStop = "${pkgs.rabbitmq_server}/sbin/rabbitmqctl stop";
|
||||
User = "rabbitmq";
|
||||
Group = "rabbitmq";
|
||||
PermissionsStartOnly = true;
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
};
|
||||
|
||||
postStart = ''
|
||||
rabbitmqctl wait ${cfg.dataDir}/pid
|
||||
'';
|
||||
|
||||
preStart = ''
|
||||
mkdir -p ${cfg.dataDir} && chmod 0700 ${cfg.dataDir}
|
||||
if [ "$(id -u)" = 0 ]; then chown rabbitmq:rabbitmq ${cfg.dataDir}; fi
|
||||
|
||||
${optionalString (cfg.cookie != "") ''
|
||||
echo -n ${cfg.cookie} > ${cfg.dataDir}/.erlang.cookie
|
||||
chmod 400 ${cfg.dataDir}/.erlang.cookie
|
||||
chown rabbitmq:rabbitmq ${cfg.dataDir}/.erlang.cookie
|
||||
''}
|
||||
|
||||
mkdir -p /var/log/rabbitmq && chmod 0700 /var/log/rabbitmq
|
||||
chown rabbitmq:rabbitmq /var/log/rabbitmq
|
||||
'';
|
||||
|
||||
postStart = mkBefore "until rabbitmqctl status; do sleep 1; done";
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue