Add configuration to run service using uwsgi
Add a sample configuration for running the wsgi transport using uwsgi, and make devstack uses it, while running zaqar-server with websocket transport. This allows running both websockets and wsgi transports on devstack. Change-Id: Ifac7461ec6b0501b1b9021030d9c173cf368a59b
This commit is contained in:
parent
55f1e3dbd1
commit
ec0b1c5150
@ -14,7 +14,7 @@
|
||||
|
||||
# This script is executed inside gate_hook function in devstack gate.
|
||||
|
||||
ENABLED_SERVICES="mysql,key,tempest,zaqar-server,"
|
||||
ENABLED_SERVICES="mysql,key,tempest,zaqar-websocket,zaqar-wsgi"
|
||||
|
||||
export DEVSTACK_GATE_ZAQAR=1
|
||||
export DEVSTACK_GATE_INSTALL_TESTONLY=1
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
# To enable a minimal set of Zaqar services, add the following to localrc:
|
||||
#
|
||||
# enable_service zaqar-server
|
||||
# enable_service zaqar-websocket zaqar-wsgi
|
||||
#
|
||||
# Dependencies:
|
||||
# - functions
|
||||
@ -37,6 +37,7 @@ ZAQAR_DIR=$DEST/zaqar
|
||||
ZAQARCLIENT_DIR=$DEST/python-zaqarclient
|
||||
ZAQAR_CONF_DIR=/etc/zaqar
|
||||
ZAQAR_CONF=$ZAQAR_CONF_DIR/zaqar.conf
|
||||
ZAQAR_UWSGI_CONF=$ZAQAR_CONF_DIR/uwsgi.conf
|
||||
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}
|
||||
@ -59,6 +60,7 @@ ZAQARCLIENT_BRANCH=${ZAQARCLIENT_BRANCH:-master}
|
||||
# Set Zaqar Connection Info
|
||||
ZAQAR_SERVICE_HOST=${ZAQAR_SERVICE_HOST:-$SERVICE_HOST}
|
||||
ZAQAR_SERVICE_PORT=${ZAQAR_SERVICE_PORT:-8888}
|
||||
ZAQAR_WEBSOCKET_PORT=${ZAQAR_WEBSOCKET_PORT:-9000}
|
||||
ZAQAR_SERVICE_PROTOCOL=${ZAQAR_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
|
||||
|
||||
# Tell Tempest this project is present
|
||||
@ -123,7 +125,9 @@ function configure_zaqar {
|
||||
|
||||
# Enable pooling by default for now
|
||||
iniset $ZAQAR_CONF DEFAULT admin_mode True
|
||||
iniset $ZAQAR_CONF 'drivers:transport:wsgi' bind $ZAQAR_SERVICE_HOST
|
||||
iniset $ZAQAR_CONF 'drivers:transport:websocket' bind $ZAQAR_SERVICE_HOST
|
||||
iniset $ZAQAR_CONF 'drivers:transport:websocket' port $ZAQAR_WEBSOCKET_PORT
|
||||
iniset $ZAQAR_CONF drivers transport websocket
|
||||
|
||||
configure_auth_token_middleware $ZAQAR_CONF zaqar $ZAQAR_AUTH_CACHE_DIR
|
||||
|
||||
@ -151,6 +155,13 @@ function configure_zaqar {
|
||||
fi
|
||||
iniset_rpc_backend zaqar $ZAQAR_CONF DEFAULT
|
||||
|
||||
pip_install uwsgi
|
||||
iniset $ZAQAR_UWSGI_CONF uwsgi http $ZAQAR_SERVICE_HOST:$ZAQAR_SERVICE_PORT
|
||||
iniset $ZAQAR_UWSGI_CONF uwsgi processes 1
|
||||
iniset $ZAQAR_UWSGI_CONF uwsgi threads 4
|
||||
iniset $ZAQAR_UWSGI_CONF uwsgi wsgi-file $ZAQAR_DIR/zaqar/transport/wsgi/app.py
|
||||
iniset $ZAQAR_UWSGI_CONF uwsgi callable app
|
||||
|
||||
cleanup_zaqar
|
||||
}
|
||||
|
||||
@ -169,6 +180,7 @@ function configure_redis {
|
||||
function configure_mongodb {
|
||||
# Set nssize to 2GB. This increases the number of namespaces supported
|
||||
# # per database.
|
||||
pip_install pymongo
|
||||
if is_ubuntu; then
|
||||
install_package mongodb-server
|
||||
sudo sed -i -e "
|
||||
@ -206,9 +218,11 @@ function install_zaqarclient {
|
||||
# start_zaqar() - Start running processes, including screen
|
||||
function start_zaqar {
|
||||
if [[ "$USE_SCREEN" = "False" ]]; then
|
||||
run_process zaqar-server "zaqar-server --config-file $ZAQAR_CONF --daemon"
|
||||
run_process zaqar-wsgi "uwsgi --ini $ZAQAR_UWSGI_CONF --daemonize $ZAQAR_API_LOG_DIR/uwsgi.log"
|
||||
run_process zaqar-websocket "zaqar-server --config-file $ZAQAR_CONF --daemon"
|
||||
else
|
||||
run_process zaqar-server "zaqar-server --config-file $ZAQAR_CONF"
|
||||
run_process zaqar-wsgi "uwsgi --ini $ZAQAR_UWSGI_CONF"
|
||||
run_process zaqar-websocket "zaqar-server --config-file $ZAQAR_CONF"
|
||||
fi
|
||||
|
||||
echo "Waiting for Zaqar to start..."
|
||||
@ -221,7 +235,7 @@ function start_zaqar {
|
||||
function stop_zaqar {
|
||||
local serv
|
||||
# Kill the zaqar screen windows
|
||||
for serv in zaqar-server; do
|
||||
for serv in zaqar-wsgi zaqar-websocket; do
|
||||
screen -S $SCREEN_NAME -p $serv -X kill
|
||||
done
|
||||
}
|
||||
@ -238,14 +252,19 @@ function create_zaqar_accounts {
|
||||
"$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"
|
||||
|
||||
local zaqar_ws_service=$(get_or_create_service "zaqar-websocket" \
|
||||
"messaging-websocket" "Zaqar Service")
|
||||
get_or_create_endpoint $zaqar_service \
|
||||
"$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
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if is_service_enabled zaqar-server; then
|
||||
if is_service_enabled zaqar-websocket || is_service_enabled zaqar-wsgi; then
|
||||
if [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
echo_summary "Installing Zaqar"
|
||||
install_zaqarclient
|
||||
@ -268,9 +287,6 @@ if is_service_enabled zaqar-server; then
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
stop_zaqar
|
||||
fi
|
||||
|
||||
#if [[ "$1" == "clean" ]]; then
|
||||
#fi
|
||||
fi
|
||||
|
||||
# Restore xtrace
|
||||
|
@ -1,4 +1,3 @@
|
||||
# Devstack settings
|
||||
|
||||
# we have to add zaqar-server to enabled services for screen_it to work
|
||||
enable_service zaqar-server
|
||||
enable_service zaqar-websocket zaqar-wsgi
|
||||
|
7
etc/uwsgi.conf
Normal file
7
etc/uwsgi.conf
Normal file
@ -0,0 +1,7 @@
|
||||
[uwsgi]
|
||||
strict = true
|
||||
http = :8888
|
||||
processes = 1
|
||||
threads = 4
|
||||
wsgi-file = /opt/stack/zaqar/zaqar/transport/wsgi/app.py
|
||||
callable = app
|
@ -30,7 +30,7 @@ _GENERAL_OPTIONS = (
|
||||
'catalogue/control plane data is kept.'),
|
||||
deprecated_opts=[cfg.DeprecatedOpt('sharding')]),
|
||||
cfg.BoolOpt('unreliable', default=None,
|
||||
help='Disable all reliability constrains.'),
|
||||
help='Disable all reliability constraints.'),
|
||||
)
|
||||
|
||||
_DRIVER_OPTIONS = (
|
||||
|
@ -33,6 +33,9 @@ _WS_OPTIONS = (
|
||||
cfg.IntOpt('port', default=9000,
|
||||
help='Port on which the self-hosting server will listen.'),
|
||||
|
||||
cfg.IntOpt('external-port', default=None,
|
||||
help='Port on which the service is provided to the user.'),
|
||||
|
||||
cfg.BoolOpt('debug', default=False, help='Print debugging output')
|
||||
)
|
||||
|
||||
@ -58,8 +61,9 @@ class Driver(object):
|
||||
@decorators.lazy_property(write=False)
|
||||
def factory(self):
|
||||
uri = 'ws://' + self._ws_conf.bind + ':' + str(self._ws_conf.port)
|
||||
return factory.ProtocolFactory(uri, debug=self._ws_conf.debug,
|
||||
handler=self._api)
|
||||
return factory.ProtocolFactory(
|
||||
uri, debug=self._ws_conf.debug, handler=self._api,
|
||||
external_port=self._ws_conf.external_port)
|
||||
|
||||
def listen(self):
|
||||
"""Self-host using 'bind' and 'port' from the WS config group."""
|
||||
|
@ -22,8 +22,9 @@ class ProtocolFactory(websocket.WebSocketServerFactory):
|
||||
|
||||
protocol = protocol.MessagingProtocol
|
||||
|
||||
def __init__(self, uri, debug, handler):
|
||||
websocket.WebSocketServerFactory.__init__(self, uri, debug)
|
||||
def __init__(self, uri, debug, handler, external_port):
|
||||
websocket.WebSocketServerFactory.__init__(
|
||||
self, url=uri, debug=debug, externalPort=external_port)
|
||||
self._handler = handler
|
||||
|
||||
def __call__(self):
|
||||
|
@ -36,4 +36,6 @@ from zaqar import bootstrap
|
||||
conf = cfg.CONF
|
||||
conf(project='zaqar', prog='zaqar-queues', args=[])
|
||||
|
||||
app = bootstrap.Bootstrap(conf).transport.app
|
||||
boot = bootstrap.Bootstrap(conf)
|
||||
conf.drivers.transport = 'wsgi'
|
||||
app = boot.transport.app
|
||||
|
Loading…
Reference in New Issue
Block a user