From 347d3a8fefa47a3e5cc0b282d9cf2cdec8ccdaec Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 25 Nov 2024 03:28:50 +0900 Subject: [PATCH] Use common helper to generate uwsgi setting ... to reduce own logic in our devstack plugin. Note that this adds apache web server in front of zaqar-api run by uwsgi, following the standard architecture in devstack. Change-Id: I0e7f48c8568fe461304e6e39d9f61c4268154a6f --- devstack/plugin.sh | 46 ++++++++++-------------------------- devstack/settings | 2 +- devstack/upgrade/shutdown.sh | 4 +--- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 3a3bac32f..4a8f7c873 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -46,6 +46,7 @@ function cleanup_zaqar { if [ "$ZAQAR_BACKEND" = 'mongodb' ] ; then cleanup_zaqar_mongodb fi + remove_uwsgi_config "$ZAQAR_UWSGI_CONF" "zaqar" } # cleanup_zaqar_mongodb() - Remove residual data files, anything left over from previous @@ -147,23 +148,7 @@ function configure_zaqar { fi iniset_rpc_backend zaqar $ZAQAR_CONF DEFAULT - pip_install uwsgi - - iniset $ZAQAR_UWSGI_CONF uwsgi master true - iniset $ZAQAR_UWSGI_CONF uwsgi die-on-term true - iniset $ZAQAR_UWSGI_CONF uwsgi exit-on-reload true - iniset $ZAQAR_UWSGI_CONF uwsgi http $ZAQAR_SERVICE_HOST:$ZAQAR_SERVICE_PORT - iniset $ZAQAR_UWSGI_CONF uwsgi processes $API_WORKERS - iniset $ZAQAR_UWSGI_CONF uwsgi enable_threads true - iniset $ZAQAR_UWSGI_CONF uwsgi threads 4 - iniset $ZAQAR_UWSGI_CONF uwsgi thunder-lock true - iniset $ZAQAR_UWSGI_CONF uwsgi buffer-size 65535 - iniset $ZAQAR_UWSGI_CONF uwsgi wsgi-file $ZAQAR_DIR/zaqar/transport/wsgi/app.py - iniset $ZAQAR_UWSGI_CONF uwsgi master true - iniset $ZAQAR_UWSGI_CONF uwsgi add-header "Connection: close" - iniset $ZAQAR_UWSGI_CONF uwsgi lazy-apps true - - cleanup_zaqar + write_uwsgi_config "$ZAQAR_UWSGI_CONF" "$ZAQAR_UWSGI" "/messaging" "" "zaqar" } function configure_redis { @@ -238,6 +223,7 @@ function install_zaqar { if is_service_enabled horizon; then install_zaqarui fi + pip_install uwsgi } function install_zaqarui { @@ -266,14 +252,14 @@ function install_zaqarclient { # start_zaqar() - Start running processes, including screen function start_zaqar { - cat $ZAQAR_UWSGI_CONF - run_process zaqar-wsgi "$ZAQAR_BIN_DIR/uwsgi --ini $ZAQAR_UWSGI_CONF --pidfile2 $ZAQAR_UWSGI_MASTER_PIDFILE" + run_process zaqar-wsgi "$ZAQAR_BIN_DIR/uwsgi --ini $ZAQAR_UWSGI_CONF" run_process zaqar-websocket "$ZAQAR_BIN_DIR/zaqar-server --config-file $ZAQAR_CONF" echo "Waiting for Zaqar to start..." local www_authenticate_uri=http://${ZAQAR_SERVICE_HOST}/identity + local ping_url=$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST/messaging/v2/ping token=$(openstack token issue -c id -f value --os-auth-url ${www_authenticate_uri}) - if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q --header=\"Client-ID:$(uuidgen)\" --header=\"X-Auth-Token:$token\" -O- $ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST:$ZAQAR_SERVICE_PORT/v2/ping; do sleep 1; done"; then + if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q --header=\"Client-ID:$(uuidgen)\" --header=\"X-Auth-Token:$token\" -O- $ping_url; do sleep 1; done"; then die $LINENO "Zaqar did not start" fi } @@ -283,9 +269,8 @@ function stop_zaqar { local serv # Kill the zaqar screen windows for serv in zaqar-wsgi zaqar-websocket; do - screen -S $SCREEN_NAME -p $serv -X kill + stop_process serv done - uwsgi --stop $ZAQAR_UWSGI_MASTER_PIDFILE } function create_zaqar_accounts { @@ -293,20 +278,15 @@ function create_zaqar_accounts { if [[ "$KEYSTONE_IDENTITY_BACKEND" = 'sql' ]]; then - local zaqar_service=$(get_or_create_service "zaqar" \ - "messaging" "Zaqar Service") - get_or_create_endpoint $zaqar_service \ + get_or_create_service "zaqar" "messaging" "Zaqar Service" + get_or_create_endpoint "messaging" \ "$REGION_NAME" \ - "$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST:$ZAQAR_SERVICE_PORT" \ - "$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST:$ZAQAR_SERVICE_PORT" \ - "$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST:$ZAQAR_SERVICE_PORT" + "$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST/messaging" - local zaqar_ws_service=$(get_or_create_service "zaqar-websocket" \ - "messaging-websocket" "Zaqar Websocket Service") - get_or_create_endpoint $zaqar_ws_service \ + get_or_create_service "zaqar-websocket" \ + "messaging-websocket" "Zaqar Websocket Service" + get_or_create_endpoint "messaging-websocket" \ "$REGION_NAME" \ - "$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST:$ZAQAR_WEBSOCKET_PORT" \ - "$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST:$ZAQAR_WEBSOCKET_PORT" \ "$ZAQAR_SERVICE_PROTOCOL://$ZAQAR_SERVICE_HOST:$ZAQAR_WEBSOCKET_PORT" fi diff --git a/devstack/settings b/devstack/settings index e2401b1a8..0366d90ca 100644 --- a/devstack/settings +++ b/devstack/settings @@ -7,7 +7,7 @@ ZAQAR_CONF_DIR=/etc/zaqar ZAQAR_CONF=$ZAQAR_CONF_DIR/zaqar.conf ZAQAR_POLICY_CONF=$ZAQAR_CONF_DIR/policy.yaml ZAQAR_UWSGI_CONF=$ZAQAR_CONF_DIR/uwsgi.conf -ZAQAR_UWSGI_MASTER_PIDFILE=/tmp/uwsgizaqarmasterprocess.pid +ZAQAR_UWSGI=$ZAQAR_DIR/zaqar/transport/wsgi/app.py ZAQAR_API_LOG_DIR=/var/log/zaqar ZAQAR_API_LOG_FILE=$ZAQAR_API_LOG_DIR/queues.log ZAQAR_AUTH_CACHE_DIR=${ZAQAR_AUTH_CACHE_DIR:-/var/cache/zaqar} diff --git a/devstack/upgrade/shutdown.sh b/devstack/upgrade/shutdown.sh index 4df9d6157..5638fcf77 100755 --- a/devstack/upgrade/shutdown.sh +++ b/devstack/upgrade/shutdown.sh @@ -19,8 +19,6 @@ source $ZAQAR_DEVSTACK_DIR/plugin.sh set -o xtrace -for serv in zaqar-websocket; do +for serv in zaqar-wsgi zaqar-websocket; do stop_process $serv done - -uwsgi --stop $ZAQAR_UWSGI_MASTER_PIDFILE \ No newline at end of file