Don't start telegraf when stale pidfile found (#5731)

This commit is contained in:
Daniel Nelson 2019-04-17 15:47:03 -07:00 committed by GitHub
parent 2faf37e5c1
commit bc95a2a2b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 11 deletions

View File

@ -120,13 +120,13 @@ confdir=/etc/telegraf/telegraf.d
case $1 in case $1 in
start) start)
# Checked the PID file exists and check the actual status of process # Checked the PID file exists and check the actual status of process
if [ -e $pidfile ]; then if [ -e "$pidfile" ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?" if pidofproc -p $pidfile $daemon > /dev/null; then
# If the status is SUCCESS then don't need to start again. log_failure_msg "$name process is running"
if [ "x$status" = "x0" ]; then else
log_failure_msg "$name process is running" log_failure_msg "$name pidfile has no corresponding process; ensure $name is stopped and remove $pidfile"
exit 0 # Exit fi
fi exit 0
fi fi
# Bump the file limits, before launching the daemon. These will carry over to # Bump the file limits, before launching the daemon. These will carry over to
@ -150,8 +150,7 @@ case $1 in
stop) stop)
# Stop the daemon. # Stop the daemon.
if [ -e $pidfile ]; then if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?" if pidofproc -p $pidfile $daemon > /dev/null; then
if [ "$status" = 0 ]; then
# periodically signal until process exists # periodically signal until process exists
while true; do while true; do
if ! pidofproc -p $pidfile $daemon > /dev/null; then if ! pidofproc -p $pidfile $daemon > /dev/null; then
@ -172,8 +171,7 @@ case $1 in
reload) reload)
# Reload the daemon. # Reload the daemon.
if [ -e $pidfile ]; then if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?" if pidofproc -p $pidfile $daemon > /dev/null; then
if [ "$status" = 0 ]; then
if killproc -p $pidfile SIGHUP; then if killproc -p $pidfile SIGHUP; then
log_success_msg "$name process was reloaded" log_success_msg "$name process was reloaded"
else else