Browse code

Convert placement to new uwsgi mode

This converts the placement API to use the new WSGI_MODE variable
(which is not introduced until the next changeset). We do this so that
placement and keystone patches can be reviewed independently, but
there are some hidden coupling of mod_wsgi setup which happens only in
keystone, so if we do keystone first, it breaks placement.

Change-Id: Id5b2c67701bcc7b12c8e3764c7199d10f85df80f

Sean Dague authored on 2017/04/14 02:36:42
Showing 1 changed files
... ...
@@ -32,7 +32,15 @@ set +o xtrace
32 32
 PLACEMENT_CONF_DIR=/etc/nova
33 33
 PLACEMENT_CONF=$PLACEMENT_CONF_DIR/nova.conf
34 34
 PLACEMENT_AUTH_STRATEGY=${PLACEMENT_AUTH_STRATEGY:-placement}
35
-
35
+# Nova virtual environment
36
+if [[ ${USE_VENV} = True ]]; then
37
+    PROJECT_VENV["nova"]=${NOVA_DIR}.venv
38
+    PLACEMENT_BIN_DIR=${PROJECT_VENV["nova"]}/bin
39
+else
40
+    PLACEMENT_BIN_DIR=$(get_python_exec_prefix)
41
+fi
42
+PLACEMENT_UWSGI=$PLACEMENT_BIN_DIR/nova-placement-api
43
+PLACEMENT_UWSGI_CONF=$PLACEMENT_CONF_DIR/placement-uwsgi.ini
36 44
 
37 45
 # The placement service can optionally use a separate database
38 46
 # connection. Set PLACEMENT_DB_ENABLED to True to use it.
... ...
@@ -114,7 +122,13 @@ function configure_placement {
114 114
     if [ "$PLACEMENT_DB_ENABLED" != False ]; then
115 115
         iniset $PLACEMENT_CONF placement_database connection `database_connection_url placement`
116 116
     fi
117
-    _config_placement_apache_wsgi
117
+    # TODO(sdague): this really should flag off of something else, but
118
+    # it won't really work without systemd today.
119
+    if [[ "$WSGI_MODE" == "uwsgi" ]]; then
120
+        write_uwsgi_config "$PLACEMENT_UWSGI_CONF" "$PLACEMENT_UWSGI" "/placement"
121
+    else
122
+        _config_placement_apache_wsgi
123
+    fi
118 124
 }
119 125
 
120 126
 # create_placement_accounts() - Set up required placement accounts
... ...
@@ -147,9 +161,13 @@ function install_placement {
147 147
 
148 148
 # start_placement_api() - Start the API processes ahead of other things
149 149
 function start_placement_api {
150
-    enable_apache_site placement-api
151
-    restart_apache_server
152
-    tail_log placement-api /var/log/$APACHE_NAME/placement-api.log
150
+    if [[ "$WSGI_MODE" == "uwsgi" ]]; then
151
+        run_process "placement-api" "$PLACEMENT_BIN_DIR/uwsgi --ini $PLACEMENT_UWSGI_CONF"
152
+    else
153
+        enable_apache_site placement-api
154
+        restart_apache_server
155
+        tail_log placement-api /var/log/$APACHE_NAME/placement-api.log
156
+    fi
153 157
 
154 158
     echo "Waiting for placement-api to start..."
155 159
     if ! wait_for_service $SERVICE_TIMEOUT $PLACEMENT_SERVICE_PROTOCOL://$PLACEMENT_SERVICE_HOST/placement; then
... ...
@@ -163,8 +181,13 @@ function start_placement {
163 163
 
164 164
 # stop_placement() - Disable the api service and stop it.
165 165
 function stop_placement {
166
-    disable_apache_site placement-api
167
-    restart_apache_server
166
+    if [[ "$WSGI_MODE" == "uwsgi" ]]; then
167
+        stop_process "placement-api"
168
+        remove_uwsgi_config "$PLACEMENT_UWSGI_CONF" "$PLACEMENT_UWSGI"
169
+    else
170
+        disable_apache_site placement-api
171
+        restart_apache_server
172
+    fi
168 173
 }
169 174
 
170 175
 # Restore xtrace