* Idem for zabbix-agent.
svn path=/nixos/trunk/; revision=20040
This commit is contained in:
parent
9127795e4a
commit
f013236f1e
|
@ -76,20 +76,29 @@ in
|
|||
''
|
||||
mkdir -m 0755 -p ${stateDir} ${logDir}
|
||||
chown zabbix ${stateDir} ${logDir}
|
||||
|
||||
# Grrr, zabbix_agentd cannot be properly monitored by
|
||||
# Upstart. Upstart's "expect fork/daemon" feature doesn't
|
||||
# work because zabbix_agentd runs some programs on
|
||||
# startup, and zabbix_agentd doesn't have a flag to
|
||||
# prevent daemonizing.
|
||||
export PATH=${pkgs.nettools}/bin:$PATH
|
||||
${pkgs.zabbix.agent}/sbin/zabbix_agentd --config ${configFile}
|
||||
'';
|
||||
|
||||
# Zabbix doesn't have an option not to daemonize, and doesn't
|
||||
# daemonize in a way that allows Upstart to track it. So to
|
||||
# make sure that we notice when it goes down, we start Zabbix
|
||||
# with an open connection to a fifo, with a `cat' on the other
|
||||
# side. If Zabbix dies, then `cat' will exit as well, so we
|
||||
# just monitor `cat'.
|
||||
script =
|
||||
''
|
||||
export PATH=${pkgs.nettools}/bin:$PATH
|
||||
rm -f ${stateDir}/dummy2
|
||||
mkfifo ${stateDir}/dummy2
|
||||
cat ${stateDir}/dummy2 &
|
||||
pid=$!
|
||||
${pkgs.zabbix.agent}/sbin/zabbix_agentd --config ${configFile} 100>${stateDir}/dummy2
|
||||
wait "$pid"
|
||||
'';
|
||||
|
||||
postStop =
|
||||
''
|
||||
pid=$(cat ${pidFile})
|
||||
test -n "$pid" && kill "$pid"
|
||||
pid=$(cat ${pidFile} 2> /dev/null || true)
|
||||
(test -n "$pid" && kill "$pid") || true
|
||||
# Wait until they're really gone.
|
||||
while ${pkgs.procps}/bin/pgrep -u zabbix zabbix_agentd > /dev/null; do sleep 1; done
|
||||
'';
|
||||
|
|
Loading…
Reference in New Issue