From 6a37e004395d5e1c57ee0bd6f88c2c491315f5ba Mon Sep 17 00:00:00 2001 From: Mark Unsworth Date: Sat, 27 Sep 2014 21:11:41 +0100 Subject: [PATCH 1/4] Replaced use of $LABEL with $NAME $LABEL does not exist so results in annoying output. e.g is running instead of: supervisord is running --- templates/default/debian/supervisor.init.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/default/debian/supervisor.init.erb b/templates/default/debian/supervisor.init.erb index 14dd21e..c338cea 100644 --- a/templates/default/debian/supervisor.init.erb +++ b/templates/default/debian/supervisor.init.erb @@ -79,7 +79,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 @@ -147,7 +147,7 @@ case "$1" in echo "$NAME." ;; status) - echo -n "$LABEL is " + echo -n "$NAME is " if running ; then echo "running" else From 8e743732a4f3a7236badf2c5a3743af8a8dbe490 Mon Sep 17 00:00:00 2001 From: Mark Unsworth Date: Sat, 27 Sep 2014 21:29:47 +0100 Subject: [PATCH 2/4] made the DODTIME (time to wait when restarting/forcing stop) configurable. Set the default value to be 10 secs the same as the default stopwait time in the process configuration --- attributes/default.rb | 3 +++ templates/default/debian/supervisor.init.erb | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 2b26c41..d5069df 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -37,3 +37,6 @@ default['supervisor']['minfds'] = 1024 default['supervisor']['minprocs'] = 200 default['supervisor']['socket_file'] = '/var/run/supervisor.sock' + +default['supervisor']['init_script']['stop_wait_secs'] = 10 + diff --git a/templates/default/debian/supervisor.init.erb b/templates/default/debian/supervisor.init.erb index c338cea..8a4859b 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=<%= default['supervisor']['init_script']['stop_wait_secs'] %> # Include supervisor defaults if available if [ -f /etc/default/supervisor ] ; then From 0c5f9ec59efad13c88dbd4a0211b8507ce282ebc Mon Sep 17 00:00:00 2001 From: Mark Unsworth Date: Sat, 27 Sep 2014 21:57:17 +0100 Subject: [PATCH 3/4] added a check to see if the service is still running after waiting. If it is call force_stop. --- templates/default/debian/supervisor.init.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/default/debian/supervisor.init.erb b/templates/default/debian/supervisor.init.erb index 8a4859b..c75499f 100644 --- a/templates/default/debian/supervisor.init.erb +++ b/templates/default/debian/supervisor.init.erb @@ -145,6 +145,9 @@ 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." From 57ac9fec9f8267659f08b47ae681fb810aa88d80 Mon Sep 17 00:00:00 2001 From: Mark Unsworth Date: Sat, 27 Sep 2014 22:21:42 +0100 Subject: [PATCH 4/4] fixed bad reference to attribute --- templates/default/debian/supervisor.init.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/debian/supervisor.init.erb b/templates/default/debian/supervisor.init.erb index c75499f..5d836ab 100644 --- a/templates/default/debian/supervisor.init.erb +++ b/templates/default/debian/supervisor.init.erb @@ -38,7 +38,7 @@ PIDFILE=/var/run/$NAME.pid # let some servers to die gracefully and # 'restart' will not work -DODTIME=<%= default['supervisor']['init_script']['stop_wait_secs'] %> +DODTIME=<%= node['supervisor']['init_script']['stop_wait_secs'] %> # Include supervisor defaults if available if [ -f /etc/default/supervisor ] ; then