Add reload configuration for telegraf service scripts.

closes #794
This commit is contained in:
HUANG Wei 2016-03-05 11:11:53 +08:00 committed by Cameron Sparr
parent c2bb9db012
commit f8e9fafda3
2 changed files with 17 additions and 0 deletions

View File

@ -159,6 +159,22 @@ case $1 in
fi
;;
reload)
# Reload the daemon.
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
if [ "$status" = 0 ]; then
if killproc -p $pidfile SIGHUP; then
log_success_msg "$name process was reloaded"
else
log_failure_msg "$name failed to reload service"
fi
fi
else
log_failure_msg "$name process is not running"
fi
;;
restart)
# Restart the daemon.
$0 stop && sleep 2 && $0 start

View File

@ -7,6 +7,7 @@ After=network.target
EnvironmentFile=-/etc/default/telegraf
User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d ${TELEGRAF_OPTS}
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
KillMode=process