upstream/openstack/python-horizon/centos/files/horizon.init
Tyler Smith 9d0c89a76c Removing horizon-region-exclusion support
This functionality is no longer supported with vanilla
horizon so this config file is being removed.

Change-Id: I15896eba1403a89aa0cdfa7f4df6c4c04baf9752
Story: 2004520
Task: 30987
Signed-off-by: Tyler Smith <tyler.smith@windriver.com>
2019-05-22 21:16:36 +00:00

153 lines
4.0 KiB
Bash
Executable File

#!/bin/sh
### BEGIN INIT INFO
# Provides: OpenStack Dashboard
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenStack Dashboard
# Description: Web based user interface to OpenStack services including
# Nova, Swift, Keystone, etc.
### END INIT INFO
RETVAL=0
DESC="openstack-dashboard"
PIDFILE="/var/run/$DESC.pid"
PYTHON=`which python`
# Centos packages openstack_dashboard under /usr/share
#MANAGE="@PYTHON_SITEPACKAGES@/openstack_dashboard/manage.py"
MANAGE="/usr/share/openstack-dashboard/manage.py"
EXEC="/usr/bin/gunicorn"
BIND="localhost"
PORT="8008"
WORKER="eventlet"
WORKERS=`grep workers /etc/openstack-dashboard/horizon-config.ini | cut -f3 -d' '`
# Increased timeout to facilitate large image uploads
TIMEOUT="200"
STATICDIR="/www/pages/static"
BRANDDIR="/opt/branding"
APPLIEDDIR="/opt/branding/applied"
TMPUPLOADDIR="/scratch/horizon"
source /usr/bin/tsconfig
start()
{
# Change workers if combined controller/compute
. /etc/platform/platform.conf
if [ "${WORKERS}" -lt "2" ]; then
WORKERS=2
fi
if [ -e $PIDFILE ]; then
PIDDIR=/proc/$(cat $PIDFILE)
if [ -d ${PIDDIR} ]; then
echo "$DESC already running."
return
else
echo "Removing stale PID file $PIDFILE"
rm -f $PIDFILE
fi
fi
# Clean up any possible orphaned worker threads
if lsof -t -i:${PORT} 1> /dev/null 2>&1; then
kill $(lsof -t -i:${PORT}) > /dev/null 2>&1
fi
rm -rf ${TMPUPLOADDIR}
mkdir -p ${TMPUPLOADDIR}
echo -n "Starting $DESC..."
start-stop-daemon --start --quiet --background --pidfile ${PIDFILE} \
--make-pidfile --exec ${PYTHON} -- ${EXEC} --bind ${BIND}:${PORT} \
--worker-class ${WORKER} --workers ${WORKERS} --timeout ${TIMEOUT} \
--log-syslog \
--config '/usr/share/openstack-dashboard/guni_config.py' \
--pythonpath '/usr/share/openstack-dashboard' \
openstack_dashboard.wsgi
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "done."
else
echo "failed."
fi
# now copy customer branding file to CONFIG_PATH/branding if anything updated
sm-query service drbd-platform | grep enabled-active > /dev/null 2>&1
IS_ACTIVE=$?
if ls ${BRANDDIR}/*.tgz 1> /dev/null 2>&1; then
LATESTBRANDING=$(ls $BRANDDIR |grep '\.tgz$' | tail -n 1)
if [ $IS_ACTIVE -eq 0 ]; then
# Only do the copy if the tarball has changed
if ! cmp --silent ${BRANDDIR}/${LATESTBRANDING} ${CONFIG_PATH}/branding/${LATESTBRANDING} ; then
mkdir -p ${CONFIG_PATH}/branding
rm -rf ${CONFIG_PATH}/branding/*.tgz
cp -r ${BRANDDIR}/${LATESTBRANDING} ${CONFIG_PATH}/branding
fi
fi
fi
# As part of starting horizon we should kill containerized horizon so that it
# will pickup branding changes
kubectl --kubeconfig=/etc/kubernetes/admin.conf delete pods -n openstack -l application=horizon 1>/dev/null
}
stop()
{
if [ ! -e $PIDFILE ]; then return; fi
echo -n "Stopping $DESC..."
start-stop-daemon --stop --quiet --pidfile $PIDFILE
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "done."
else
echo "failed."
fi
rm -rf ${TMPUPLOADDIR}
rm -f $PIDFILE
}
status()
{
pid=`cat $PIDFILE 2>/dev/null`
if [ -n "$pid" ]; then
if ps -p $pid &> /dev/null ; then
echo "$DESC is running"
RETVAL=0
return
else
RETVAL=1
fi
fi
echo "$DESC is not running"
RETVAL=3
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
RETVAL=1
;;
esac
exit $RETVAL