Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't start telegraf when stale pidfile found #5731

Merged
merged 1 commit into from
Apr 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ confdir=/etc/telegraf/telegraf.d
case $1 in
start)
# Checked the PID file exists and check the actual status of process
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
# If the status is SUCCESS then don't need to start again.
if [ "x$status" = "x0" ]; then
log_failure_msg "$name process is running"
exit 0 # Exit
fi
if [ -e "$pidfile" ]; then
if pidofproc -p $pidfile $daemon > /dev/null; then
log_failure_msg "$name process is running"
else
log_failure_msg "$name pidfile has no corresponding process; ensure $name is stopped and remove $pidfile"
fi
exit 0
fi

# Bump the file limits, before launching the daemon. These will carry over to
Expand All @@ -150,8 +150,7 @@ case $1 in
stop)
# Stop the daemon.
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
if [ "$status" = 0 ]; then
if pidofproc -p $pidfile $daemon > /dev/null; then
# periodically signal until process exists
while true; do
if ! pidofproc -p $pidfile $daemon > /dev/null; then
Expand All @@ -172,8 +171,7 @@ case $1 in
reload)
# Reload the daemon.
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
if [ "$status" = 0 ]; then
if pidofproc -p $pidfile $daemon > /dev/null; then
if killproc -p $pidfile SIGHUP; then
log_success_msg "$name process was reloaded"
else
Expand Down