collectd: add pidFile option, change default pid to /var/run/collectd.pid
This commit is contained in:
parent
e6b9656e24
commit
9c3c7a75d3
@ -7,7 +7,7 @@ let
|
|||||||
|
|
||||||
conf = pkgs.writeText "collectd.conf" ''
|
conf = pkgs.writeText "collectd.conf" ''
|
||||||
BaseDir "${cfg.dataDir}"
|
BaseDir "${cfg.dataDir}"
|
||||||
PIDFile "${cfg.dataDir}/collectd.pid"
|
PIDFile "${cfg.pidFile}"
|
||||||
AutoLoadPlugin ${if cfg.autoLoadPlugin then "true" else "false"}
|
AutoLoadPlugin ${if cfg.autoLoadPlugin then "true" else "false"}
|
||||||
Hostname ${config.networking.hostName}
|
Hostname ${config.networking.hostName}
|
||||||
|
|
||||||
@ -50,6 +50,14 @@ in {
|
|||||||
type = path;
|
type = path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pidFile = mkOption {
|
||||||
|
default = "/var/run/collectd.pid";
|
||||||
|
description = ''
|
||||||
|
Location of collectd pid file.
|
||||||
|
'';
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
|
||||||
autoLoadPlugin = mkOption {
|
autoLoadPlugin = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
@ -83,16 +91,20 @@ in {
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${pkgs.collectd}/sbin/collectd -C ${conf} -P ${cfg.dataDir}/collectd.pid";
|
ExecStart = "${pkgs.collectd}/sbin/collectd -C ${conf} -P ${cfg.pidFile}";
|
||||||
Type = "forking";
|
Type = "forking";
|
||||||
PIDFile = "${cfg.dataDir}/collectd.pid";
|
PIDFile = cfg.pidFile;
|
||||||
User = optional (cfg.user!="root") cfg.user;
|
User = optional (cfg.user!="root") cfg.user;
|
||||||
PermissionsStartOnly = true;
|
PermissionsStartOnly = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -m 0700 -p ${cfg.dataDir}
|
mkdir -m 0700 -p ${cfg.dataDir}
|
||||||
if [ "$(id -u)" = 0 ]; then chown -R ${cfg.user} ${cfg.dataDir}; fi
|
install -D /dev/null ${cfg.pidFile}
|
||||||
|
if [ "$(id -u)" = 0 ]; then
|
||||||
|
chown -R ${cfg.user} ${cfg.dataDir};
|
||||||
|
chown ${cfg.user} ${cfg.pidFile}
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user