Fix supervisord start with stale pidfile

supervisord has a stale pidfile sometimes
during Fuel container upgrades.
Also corrected whitespace issues.

Reduced wait time for processes to 5s so that
init script doesn't exceed its max timeout.

Change-Id: I6e5511f5fcce0205283594a290e72084b20e6aa7
Closes-Bug: #1361756
This commit is contained in:
Matthew Mosesohn 2014-08-27 17:55:37 +04:00
parent 6f478caa91
commit 36bebf494f
5 changed files with 26 additions and 24 deletions

View File

@ -25,26 +25,24 @@
RETVAL=0
start() {
echo "Starting supervisord: "
if [ -e $PIDFILE ]; then
echo "ALREADY STARTED"
return 1
fi
echo "Starting supervisord: "
if [ -e $PIDFILE ] && supervisor_status; then
echo "ALREADY STARTED"
return 1
fi
# start supervisord with options from sysconfig (stuff like -c)
/usr/bin/supervisord $OPTIONS
# show initial startup status
/usr/bin/supervisorctl $OPTIONS status
# only create the subsyslock if we created the PIDFILE
[ -e $PIDFILE ] && touch /var/lock/subsys/supervisord
# start supervisord with options from sysconfig (stuff like -c)
/usr/bin/supervisord $OPTIONS
# show initial startup status
/usr/bin/supervisorctl $OPTIONS status
# only create the subsyslock if we created the PIDFILE
[ -e $PIDFILE ] && touch /var/lock/subsys/supervisord
}
stop() {
echo -n "Stopping supervisord: "
/usr/bin/supervisorctl $OPTIONS shutdown
if [ -n "$WAIT_FOR_SUBPROCESSES" ]; then
if [ -n "$WAIT_FOR_SUBPROCESSES" ]; then
echo "Waiting roughly 60 seconds for $PIDFILE to be removed after child processes exit"
for sleep in 2 2 2 2 4 4 4 4 8 8 8 8 last; do
if [ ! -e $PIDFILE ] ; then
@ -72,6 +70,10 @@ restart() {
start
}
supervisor_status() {
/usr/bin/supervisorctl status && kill -s 0 `cat /var/run/supervisord.pid` 2>/dev/null
return $?
}
case "$1" in
start)
start
@ -94,7 +96,7 @@ case "$1" in
RETVAL=$?
;;
status)
/usr/bin/supervisorctl status && kill -s 0 `cat /var/run/supervisord.pid` 2>/dev/null
supervisor_status
RETVAL=$?
;;
*)

View File

@ -9,7 +9,7 @@ startsecs=10
startretries=1000000
exitcodes=0,2
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/ostf-stdout.log
stdout_logfile_maxbytes=50MB

View File

@ -26,7 +26,7 @@ startretries=1000000
exitcodes=0,2
stopsignal=KILL
killasgroup=true
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/astute/app.log
stdout_logfile_maxbytes=50MB

View File

@ -28,7 +28,7 @@ startsecs=10
startretries=1000000
exitcodes=0,2
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/nailgun/uwsgi.log
stdout_capture_maxbytes=0
@ -46,7 +46,7 @@ startsecs=10
startretries=1000000
exitcodes=0
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/nailgun/assassind.log
stdout_capture_maxbytes=0
@ -64,7 +64,7 @@ startsecs=10
startretries=1000000
exitcodes=0
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/nailgun/receiverd.log
stdout_capture_maxbytes=0
@ -82,7 +82,7 @@ startsecs=10
startretries=1000000
exitcodes=0,2
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/astute/app.log
stdout_logfile_maxbytes=50MB

View File

@ -26,7 +26,7 @@ startsecs=10
startretries=1000000
exitcodes=0,2
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/nailgun/uwsgi.log
stdout_capture_maxbytes=0
@ -44,7 +44,7 @@ startsecs=10
startretries=1000000
exitcodes=0
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/nailgun/assassind.log
stdout_capture_maxbytes=0
@ -62,7 +62,7 @@ startsecs=10
startretries=1000000
exitcodes=0
stopsignal=INT
stopwaitsecs=60
stopwaitsecs=5
redirect_stderr=true
stdout_logfile=/var/log/nailgun/receiverd.log
stdout_capture_maxbytes=0