mosquitto (nixos): notify systemd when started

This commit is contained in:
Peter Hoeg 2019-03-01 18:54:24 +08:00
parent 5638a1c717
commit 0e40b7bfc2
1 changed files with 4 additions and 5 deletions

View File

@ -17,7 +17,6 @@ let
''; '';
mosquittoConf = pkgs.writeText "mosquitto.conf" '' mosquittoConf = pkgs.writeText "mosquitto.conf" ''
pid_file /run/mosquitto/pid
acl_file ${aclFile} acl_file ${aclFile}
persistence true persistence true
allow_anonymous ${boolToString cfg.allowAnonymous} allow_anonymous ${boolToString cfg.allowAnonymous}
@ -196,15 +195,15 @@ in
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network.target" ]; after = [ "network.target" ];
serviceConfig = { serviceConfig = {
Type = "forking"; Type = "notify";
NotifyAccess = "main";
User = "mosquitto"; User = "mosquitto";
Group = "mosquitto"; Group = "mosquitto";
RuntimeDirectory = "mosquitto"; RuntimeDirectory = "mosquitto";
WorkingDirectory = cfg.dataDir; WorkingDirectory = cfg.dataDir;
Restart = "on-failure"; Restart = "on-failure";
ExecStart = "${pkgs.mosquitto}/bin/mosquitto -c ${mosquittoConf} -d"; ExecStart = "${pkgs.mosquitto}/bin/mosquitto -c ${mosquittoConf}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
PIDFile = "/run/mosquitto/pid";
}; };
preStart = '' preStart = ''
rm -f ${cfg.dataDir}/passwd rm -f ${cfg.dataDir}/passwd
@ -214,7 +213,7 @@ in
if c.hashedPassword != null then if c.hashedPassword != null then
"echo '${n}:${c.hashedPassword}' >> ${cfg.dataDir}/passwd" "echo '${n}:${c.hashedPassword}' >> ${cfg.dataDir}/passwd"
else optionalString (c.password != null) else optionalString (c.password != null)
"${pkgs.mosquitto}/bin/mosquitto_passwd -b ${cfg.dataDir}/passwd ${n} ${c.password}" "${pkgs.mosquitto}/bin/mosquitto_passwd -b ${cfg.dataDir}/passwd ${n} '${c.password}'"
) cfg.users); ) cfg.users);
}; };