diff --git a/attributes/default.rb b/attributes/default.rb index d4ab44f..f604134 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -37,4 +37,5 @@ default['supervisor']['minfds'] = 1024 default['supervisor']['minprocs'] = 200 default['supervisor']['socket_file'] = '/var/run/supervisor.sock' +default['supervisor']['init_script']['stop_wait_secs'] = 10 default['supervisor']['ctlplugins'] = {} diff --git a/templates/default/debian/supervisor.init.erb b/templates/default/debian/supervisor.init.erb index 14dd21e..5d836ab 100644 --- a/templates/default/debian/supervisor.init.erb +++ b/templates/default/debian/supervisor.init.erb @@ -32,10 +32,13 @@ test -x $DAEMON || exit 0 LOGDIR=/var/log/supervisor PIDFILE=/var/run/$NAME.pid -DODTIME=5 # Time to wait for the server to die, in seconds - # If this value is set too low you might not - # let some servers to die gracefully and - # 'restart' will not work + +# Time to wait for the server to die, in seconds +# If this value is set too low you might not +# let some servers to die gracefully and +# 'restart' will not work + +DODTIME=<%= node['supervisor']['init_script']['stop_wait_secs'] %> # Include supervisor defaults if available if [ -f /etc/default/supervisor ] ; then @@ -79,7 +82,7 @@ force_stop() { kill -9 $pid [ -n "$DODTIME" ] && sleep "$DODTIME"s if running ; then - echo "Cannot kill $LABEL (pid=$pid)!" + echo "Cannot kill $NAME (pid=$pid)!" exit 1 fi fi @@ -142,12 +145,15 @@ case "$1" in echo -n "Restarting $DESC: " start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE [ -n "$DODTIME" ] && sleep $DODTIME + if running ; then + force_stop + fi start-stop-daemon --start --quiet --pidfile $PIDFILE \ --startas $DAEMON -- $DAEMON_OPTS echo "$NAME." ;; status) - echo -n "$LABEL is " + echo -n "$NAME is " if running ; then echo "running" else