Signal telegraf process until it exits (#5169)
This commit is contained in:
parent
b1baa54cc4
commit
c12eecc90e
|
@ -134,6 +134,7 @@ func (a *Agent) Run(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("D! [agent] Stopped Successfully")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,11 +152,17 @@ case $1 in
|
||||||
if [ -e $pidfile ]; then
|
if [ -e $pidfile ]; then
|
||||||
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
|
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
|
||||||
if [ "$status" = 0 ]; then
|
if [ "$status" = 0 ]; then
|
||||||
if killproc -p $pidfile SIGTERM && /bin/rm -rf $pidfile; then
|
# periodically signal until process exists
|
||||||
log_success_msg "$name process was stopped"
|
while true; do
|
||||||
else
|
if ! pidofproc -p $pidfile $daemon > /dev/null; then
|
||||||
log_failure_msg "$name failed to stop service"
|
break
|
||||||
fi
|
fi
|
||||||
|
killproc -p $pidfile SIGTERM 2>&1 >/dev/null
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
log_success_msg "$name process was stopped"
|
||||||
|
rm -f $pidfile
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
log_failure_msg "$name process is not running"
|
log_failure_msg "$name process is not running"
|
||||||
|
|
Loading…
Reference in New Issue