Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

RHEL init.d script will detect a different instance of supervisord if something else is running it. #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions templates/default/rhel/supervisor.init.erb
Expand Up @@ -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'] %> --pidfile=$PIDFILE"
RETVAL=$?
echo
[ $RETVAL -ne 0 ] && return $RETVAL
Expand All @@ -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
Expand All @@ -44,7 +57,7 @@ case "$1" in
stop
;;
status)
status supervisord
status
;;
restart)
# Exit with an error if the shutdown was not successful.
Expand Down