2 # Copyright (c) 2013-2018 Wind River Systems, Inc.
4 # SPDX-License-Identifier: Apache-2.0
8 # Provides: OpenStack Keystone-wsgi
9 # Required-Start: networking
10 # Required-Stop: networking
11 # Default-Start: 2 3 4 5
13 # Short-Description: OpenStack Keystone
14 # Description: Openstack Identitiy service running on WSGI compatable gunicorn web server
21 DESC_PUBLIC="openstack-keystone"
23 PIDFILE_PUBLIC="/var/run/$DESC_PUBLIC.pid"
27 source /etc/keystone/keystone-extra.conf
28 source /etc/platform/platform.conf
30 if [ -n ${@:2:1} ] ; then
31 if [ ${@:2:1}="--public-bind-addr" ] ; then
32 PUBLIC_BIND_ADDR_CMD=${@:3:1}
38 EXEC="/usr/bin/gunicorn"
41 # Increased timeout to facilitate large image uploads
44 # Calculate the no of workers based on the number of workers retrieved by
45 # Platform Eng which is retreived from the keystone-extra.conf
47 if [ "$system_type" == "All-in-one" ]; then
50 TIS_WORKERS_FACTOR=1.5
52 TIS_WORKERS=$(echo "${TIS_WORKERS_FACTOR}*${TIS_PUBLIC_WORKERS}"|bc )
53 TIS_WORKERS=${TIS_WORKERS%.*}
55 #--max-requests , --max-requests-jitter Configuration
56 #--max-requests = The max number of requests a worker will process before restarting
57 #--max-requests-jitter = The maximum jitter to add to the max_requests setting.
59 MAX_REQ_JITTER_CAP_FACTOR=0.5
60 MAX_REQ_JITTER_PUBLIC=$(echo "${TIS_WORKERS}*${MAX_REQ_JITTER_CAP_FACTOR}+1"|bc)
61 MAX_REQ_JITTER_PUBLIC=${MAX_REQ_JITTER_PUBLIC%.*}
66 # Got proper no of workers . Starting gunicorn now
67 echo -e "Initialising keystone service using gunicorn .. \n"
69 if [ -z "$PUBLIC_BIND_ADDR" ]; then
70 echo "Keystone floating ip not found . Cannot start services. Exiting .."
73 BIND_PUBLIC=$PUBLIC_BIND_ADDR:5000
75 if [ -e $PIDFILE_PUBLIC ]; then
76 PIDDIR=/proc/$(cat $PIDFILE_PUBLIC)
77 if [ -d ${PIDDIR} ]; then
78 echo "$DESC_PUBLIC already running."
81 echo "Removing stale PID file $PIDFILE_PUBLIC"
86 echo -e "Starting $DESC_PUBLIC...\n";
87 echo -e "Worker is ${WORKER} --workers ${TIS_WORKERS} --timeout ${TIMEOUT} --max_requests ${MAX_REQUESTS} --max_request_jitter public ${MAX_REQ_JITTER_PUBLIC}\n" ;
89 echo -e "Starting keystone process at port 5000 \n" ;
91 start-stop-daemon --start --quiet --background --pidfile ${PIDFILE_PUBLIC} \
92 --make-pidfile --exec ${PYTHON} -- ${EXEC} --bind ${BIND_PUBLIC} \
93 --worker-class ${WORKER} --workers ${TIS_WORKERS} --timeout ${TIMEOUT} \
94 --max-requests ${MAX_REQUESTS} --max-requests-jitter ${MAX_REQ_JITTER_PUBLIC} \
96 --pythonpath '/usr/share/keystone' public:application --name keystone-public
99 if [ $RETVAL -eq 0 ]; then
100 echo -e "Keystone started at port 5000... \n"
102 echo -e "Failed to start Keystone .. \n"
108 if [ -e $PIDFILE_PUBLIC ]; then
109 start-stop-daemon --stop --quiet --pidfile $PIDFILE_PUBLIC
111 if [ $RETVAL_PUBLIC -eq 0 ]; then
112 echo "Stopped $DESC_PUBLIC."
114 echo "Stopping failed - $PIDFILE_PUBLIC"
116 rm -f $PIDFILE_PUBLIC
118 echo "Already stopped - $PIDFILE_PUBLIC"
124 pid_public=`cat $PIDFILE_PUBLIC 2>/dev/null`
126 if [ -n "$pid_public" ]; then
127 echo -e "\033[32m $DESC_PUBLIC is running..\033[0m"
129 echo -e "\033[31m $DESC_PUBLIC is not running..\033[0m"
142 restart|force-reload|reload)
150 #echo "Usage: $0 {start|stop|force-reload|restart|reload|status} OR {/usr/bin/keystone-all start --public-bind-addr xxx.xxx.xxx}"