[fix] Add uwsgi entrypoint options

Changes the entrypoint.sh options for uwsgi to include:
 -b 32768 : for larger header/url handling
 --die-on-term : for more 'normal'  handling of SIGTERM
 --lazy-apps : to delay init of python until after forking workers
 --master : to provide a master process for handling request dispatch

The purpose of these changes is intended to avoid some crash behavior
that is occuring when the process being forked has an open db connection.
The --lazy-apps option should delay initialization. The other options are
recommended by uwsgi documentation, specicially the --master option.
The larger buffer size is not strictly recommended, but matters when large
headers are included.

The die-on-term option should provide better behavior in the container
environment.

Related-Change: I60adeffff5461fdda957124232bc5a606baae413
Change-Id: I70510246576a8fb6aa216e7c9c7e97c1c9ab791c
This commit is contained in:
Bryan Strassner 2018-03-27 08:54:05 -05:00 committed by Scott Hussey
parent c50501cc89
commit 4d642f849a
4 changed files with 16 additions and 24 deletions

View File

@ -63,7 +63,6 @@ def init_application():
LOG.debug('Starting WSGI application using %s configuration file.',
paste_file)
db_api.drop_db()
db_api.setup_db(CONF.database.connection)
app = deploy.loadapp('config:%s' % paste_file, name='deckhand_api')

View File

@ -211,30 +211,20 @@ def __build_tables(blob_type_obj, blob_type_list):
def register_models(engine, connection_string):
global BASE
blob_types = ((JSONB, JSONB) if 'postgresql' in connection_string
else (PickleType, oslo_types.JsonEncodedList()))
LOG.debug('Instantiating DB tables using %s, %s as the column type for '
'dictionaries, lists.', *blob_types)
LOG.debug('Instantiating DB tables using %s, %s as the column type '
'for dictionaries, lists.', *blob_types)
"""Create database tables for all models with the given engine."""
__build_tables(*blob_types)
this_module = sys.modules[__name__]
models = ['Bucket', 'Document', 'RevisionTag', 'Revision', 'Validation']
for model_name in models:
if hasattr(this_module, model_name):
model = getattr(this_module, model_name)
model.metadata.create_all(engine)
BASE.metadata.create_all(engine)
def unregister_models(engine):
"""Drop database tables for all models with the given engine."""
this_module = sys.modules[__name__]
models = ['Bucket', 'Document', 'RevisionTag', 'Revision', 'Validation']
global BASE
for model_name in models:
if hasattr(this_module, model_name):
model = getattr(this_module, model_name)
model.metadata.drop_all(engine)
BASE.metadata.drop_all(engine)

View File

@ -105,6 +105,5 @@ class TestApi(test_base.DeckhandTestCase):
mock.call('/versions', self.versions_resource())
], any_order=True)
mock_db_api.drop_db.assert_called_once_with()
mock_db_api.setup_db.assert_called_once_with(
str(mock.sentinel.db_connection))

View File

@ -36,12 +36,16 @@ DECKHAND_CONFIG_DIR=${DECKHAND_CONFIG_DIR:-"/etc/deckhand/deckhand.conf"}
# Start deckhand application
exec uwsgi \
--http :${PORT} \
-w deckhand.cmd \
-b 32768 \
--callable deckhand_callable \
--http-timeout $DECKHAND_API_TIMEOUT \
--die-on-term \
--enable-threads \
--http :${PORT} \
--http-timeout $DECKHAND_API_TIMEOUT \
-L \
--pyargv "--config-file /etc/deckhand/deckhand.conf" \
--lazy-apps \
--master \
--pyargv "--config-file ${DECKHAND_CONFIG_DIR}/deckhand.conf" \
--threads $DECKHAND_API_THREADS \
--workers $DECKHAND_API_WORKERS
--workers $DECKHAND_API_WORKERS \
-w deckhand.cmd