Skip to content

Commit

Permalink
Signal telegraf process until it exits (influxdata#5169)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored and otherpirate committed Mar 15, 2019
1 parent 92873cf commit ad17253
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (a *Agent) Run(ctx context.Context) error {
return err
}

log.Printf("D! [agent] Stopped Successfully")
return nil
}

Expand Down
16 changes: 11 additions & 5 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,17 @@ case $1 in
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
if [ "$status" = 0 ]; then
if killproc -p $pidfile SIGTERM && /bin/rm -rf $pidfile; then
log_success_msg "$name process was stopped"
else
log_failure_msg "$name failed to stop service"
fi
# periodically signal until process exists
while true; do
if ! pidofproc -p $pidfile $daemon > /dev/null; then
break
fi
killproc -p $pidfile SIGTERM 2>&1 >/dev/null
sleep 2
done

log_success_msg "$name process was stopped"
rm -f $pidfile
fi
else
log_failure_msg "$name process is not running"
Expand Down

0 comments on commit ad17253

Please sign in to comment.