murmur service: log to journald by default

Save an option to log to file with new `logFile` option.

As a side effect deprecate `pidfile` option and instead use systemd's
RuntimeDirectory.
This commit is contained in:
Nikolay Amiantov 2018-04-11 17:41:42 +03:00
parent ecb99304ff
commit f23c110692
2 changed files with 14 additions and 17 deletions

View File

@ -113,9 +113,10 @@ with lib;
# murmur # murmur
(mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ]) (mkRenamedOptionModule [ "services" "murmur" "welcome" ] [ "services" "murmur" "welcometext" ])
(mkRemovedOptionModule [ "services" "murmur" "pidfile" ] "Hardcoded to /run/murmur/murmurd.pid now")
# parsoid # parsoid
(mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] [ "services" "parsoid" "wikis" ]) (mkRemovedOptionModule [ "services" "parsoid" "interwikis" ] "Use services.parsoid.wikis instead")
# plexpy / tautulli # plexpy / tautulli
(mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ]) (mkRenamedOptionModule [ "services" "plexpy" ] [ "services" "tautulli" ])

View File

@ -4,6 +4,7 @@ with lib;
let let
cfg = config.services.murmur; cfg = config.services.murmur;
forking = cfg.logFile != null;
configFile = pkgs.writeText "murmurd.ini" '' configFile = pkgs.writeText "murmurd.ini" ''
database=/var/lib/murmur/murmur.sqlite database=/var/lib/murmur/murmur.sqlite
dbDriver=QSQLITE dbDriver=QSQLITE
@ -12,8 +13,8 @@ let
autobanTimeframe=${toString cfg.autobanTimeframe} autobanTimeframe=${toString cfg.autobanTimeframe}
autobanTime=${toString cfg.autobanTime} autobanTime=${toString cfg.autobanTime}
logfile=/var/log/murmur/murmurd.log logfile=${optionalString (cfg.logFile != null) cfg.logFile}
pidfile=${cfg.pidfile} ${optionalString forking "pidfile=/run/murmur/murmurd.pid"}
welcometext="${cfg.welcometext}" welcometext="${cfg.welcometext}"
port=${toString cfg.port} port=${toString cfg.port}
@ -78,10 +79,11 @@ in
description = "The amount of time an IP ban lasts (in seconds)."; description = "The amount of time an IP ban lasts (in seconds).";
}; };
pidfile = mkOption { logFile = mkOption {
type = types.path; type = types.nullOr types.path;
default = "/run/murmur/murmurd.pid"; default = null;
description = "Path to PID file for Murmur daemon."; example = "/var/log/murmur/murmurd.log";
description = "Path to the log file for Murmur daemon. Empty means log to journald.";
}; };
welcometext = mkOption { welcometext = mkOption {
@ -251,19 +253,13 @@ in
after = [ "network-online.target "]; after = [ "network-online.target "];
serviceConfig = { serviceConfig = {
Type = "forking"; # murmurd doesn't fork when logging to the console.
RuntimeDirectory = "murmur"; Type = if forking then "forking" else "simple";
PIDFile = cfg.pidfile; PIDFile = mkIf forking "/run/murmur/murmurd.pid";
Restart = "always"; RuntimeDirectory = mkIf forking "murmur";
User = "murmur"; User = "murmur";
ExecStart = "${pkgs.murmur}/bin/murmurd -ini ${configFile}"; ExecStart = "${pkgs.murmur}/bin/murmurd -ini ${configFile}";
PermissionsStartOnly = true;
}; };
preStart = ''
mkdir -p /var/log/murmur
chown -R murmur /var/log/murmur
'';
}; };
}; };
} }