mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
Merge pull request #5249 from wenottingham/BSD-stands-for-berkeley-system-d
Move to using systemd for service management. Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
a1d110aac7
@ -1,78 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Default configured services
|
# Redirect to systemctl
|
||||||
if [ -e /etc/debian_version ]; then
|
exec systemctl $@ ansible-tower.service
|
||||||
TOWER_CONFIG="/etc/default/ansible-tower"
|
|
||||||
else
|
|
||||||
TOWER_CONFIG="/etc/sysconfig/ansible-tower"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Load default configuration
|
|
||||||
[ -e "${TOWER_CONFIG}" ] && . "${TOWER_CONFIG}"
|
|
||||||
|
|
||||||
service_action() {
|
|
||||||
SERVICES=$TOWER_SERVICES
|
|
||||||
|
|
||||||
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
|
|
||||||
S_PID=$(pidof -x supervisord)
|
|
||||||
echo "Waiting to allow supervisor time to cleanup ... pid ${S_PID}"
|
|
||||||
if [ "${S_PID}" ]; then
|
|
||||||
i=0
|
|
||||||
while kill -0 "${S_PID}" 2> /dev/null; do
|
|
||||||
if [ $i = '60' ]; then
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
if [ $i == '0' ]; then
|
|
||||||
echo -n " ... waiting"
|
|
||||||
else
|
|
||||||
echo -n "."
|
|
||||||
fi
|
|
||||||
i=$(($i+1))
|
|
||||||
sleep 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "Ansible Tower service helper utility"
|
|
||||||
echo "Usage: $0 {start|stop|restart|status}"
|
|
||||||
}
|
|
||||||
|
|
||||||
worst_return=0
|
|
||||||
case "$1" in
|
|
||||||
help | -help | --help | -h)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
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
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
usage
|
|
||||||
worst_return=1
|
|
||||||
esac
|
|
||||||
exit $worst_return
|
|
||||||
|
Loading…
Reference in New Issue
Block a user