From f15856d542dbbf4dfe62ec29d90d6edc039724a0 Mon Sep 17 00:00:00 2001 From: HUANG Wei Date: Sat, 5 Mar 2016 11:11:53 +0800 Subject: [PATCH] Add reload configuration for telegraf service scripts. --- scripts/init.sh | 16 ++++++++++++++++ scripts/telegraf.service | 1 + 2 files changed, 17 insertions(+) diff --git a/scripts/init.sh b/scripts/init.sh index 81932bb48..09a4d24bd 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -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 diff --git a/scripts/telegraf.service b/scripts/telegraf.service index 6f4450402..dcc2b9713 100644 --- a/scripts/telegraf.service +++ b/scripts/telegraf.service @@ -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