awx/tools/scripts/ansible-tower
James Laska c7079cf338 Wait when stopping supervisor
Fixes a problem where we issue a start before supervisor has cleaned up
child pids (Ubuntu only).

Trello: https://trello.com/c/5rOxYcY5
2014-11-17 13:25:33 -05:00

64 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# ansible-tower
#
# chkconfig: - 20 80
# description: support init to manage tower and its related services
### BEGIN INIT INFO
# Required-Start: $local_fs $remote_fs $network $named
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: distcache
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: support init to manage tower and its related services
# Description: Ansible Tower provides an easy-to-use UI and dashboard, role-based access control and more for your Ansible initiative
### END INIT INFO
if [ -e /etc/debian_version ]
then
SERVICES=(postgresql redis-server apache2 supervisor)
else
SERVICES=(postgresql redis httpd supervisord)
fi
service_action() {
for svc in ${SERVICES[@]}; do
service ${svc} $1
this_return=$?
if [ $this_return -gt $worst_return ]; then
worst_return=$this_return
fi
# Allow supervisor time to cleanup child pids (ubuntu only)
if [[ ${svc} == supervisor* && ${1} == stop && -e /etc/debian_version ]]; then
echo "Waiting to allow supervisor time to cleanup ..."
sleep 5
fi
done
}
worst_return=0
case "$1" in
start)
echo "Starting Tower"
service_action start
;;
stop)
echo "Stopping Tower"
service_action stop
;;
restart)
echo "Restarting Tower"
service_action stop
service_action start
;;
status)
echo "Showing Tower Status"
service_action status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
exit $worst_return