From 0586a456bd18084a2a25903461ac451895f5ea58 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Sun, 21 Dec 2014 19:31:42 -0800 Subject: [PATCH 1/2] Implement status using only a pid file to avod conflicts --- templates/default/rhel/supervisor.init.erb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/templates/default/rhel/supervisor.init.erb b/templates/default/rhel/supervisor.init.erb index 36ba301..edc6ed3 100644 --- a/templates/default/rhel/supervisor.init.erb +++ b/templates/default/rhel/supervisor.init.erb @@ -12,11 +12,24 @@ source /etc/rc.d/init.d/functions +NAME="supervisord" +PIDFILE="/var/run/$NAME.pid" + +status() { + if [ -f $PIDFILE ]; then + echo "supervisord is running" + return 0 + else + echo "supervisord is stopped" + return 3 + fi +} + start() { echo -n "Starting supervisor: " # status() returns 0 if and only if the service is properly started. - status supervisord > /dev/null && echo "already running" && return 0 - daemon "<%= @supervisord %> -c <%= node['supervisor']['conffile'] %> <%= @node['supervisor']['daemon_options'] %>" + status > /dev/null && echo "already running" && return 0 + daemon "<%= @supervisord %> -c <%= node['supervisor']['conffile'] %> <%= @node['supervisor']['daemon_options'] %> -p $PIDFILE" RETVAL=$? echo [ $RETVAL -ne 0 ] && return $RETVAL @@ -26,7 +39,7 @@ start() { stop() { echo -n "Shutting down supervisor: " - status supervisord > /dev/null + status > /dev/null # status() returns 3 if and only if the service is properly stopped. [ $? -eq 3 ] && echo "already stopped" && return 0 killproc supervisord @@ -44,7 +57,7 @@ case "$1" in stop ;; status) - status supervisord + status ;; restart) # Exit with an error if the shutdown was not successful. From c275253b982d0432a1633d02f960284b4a5e9e8f Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Sun, 21 Dec 2014 19:42:26 -0800 Subject: [PATCH 2/2] Fix option for daemon call --- templates/default/rhel/supervisor.init.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/rhel/supervisor.init.erb b/templates/default/rhel/supervisor.init.erb index edc6ed3..e8a1cbc 100644 --- a/templates/default/rhel/supervisor.init.erb +++ b/templates/default/rhel/supervisor.init.erb @@ -29,7 +29,7 @@ start() { echo -n "Starting supervisor: " # status() returns 0 if and only if the service is properly started. status > /dev/null && echo "already running" && return 0 - daemon "<%= @supervisord %> -c <%= node['supervisor']['conffile'] %> <%= @node['supervisor']['daemon_options'] %> -p $PIDFILE" + daemon "<%= @supervisord %> -c <%= node['supervisor']['conffile'] %> <%= @node['supervisor']['daemon_options'] %> --pidfile=$PIDFILE" RETVAL=$? echo [ $RETVAL -ne 0 ] && return $RETVAL