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 Michele Fadda
parent 9bd488e5b0
commit faa5033300
2 changed files with 17 additions and 0 deletions

View File

@ -159,6 +159,22 @@ case $1 in
fi 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)
# Restart the daemon. # Restart the daemon.
$0 stop && sleep 2 && $0 start $0 stop && sleep 2 && $0 start

View File

@ -7,6 +7,7 @@ After=network.target
EnvironmentFile=-/etc/default/telegraf EnvironmentFile=-/etc/default/telegraf
User=telegraf User=telegraf
ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d ${TELEGRAF_OPTS} 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 Restart=on-failure
KillMode=process KillMode=process