diff --git a/deckhand/control/api.py b/deckhand/control/api.py index d8d2cf16..b58daba0 100644 --- a/deckhand/control/api.py +++ b/deckhand/control/api.py @@ -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') diff --git a/deckhand/db/sqlalchemy/models.py b/deckhand/db/sqlalchemy/models.py index 743de212..100e5709 100644 --- a/deckhand/db/sqlalchemy/models.py +++ b/deckhand/db/sqlalchemy/models.py @@ -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) diff --git a/deckhand/tests/unit/control/test_api_initialization.py b/deckhand/tests/unit/control/test_api_initialization.py index 374b8d49..4e399c5e 100644 --- a/deckhand/tests/unit/control/test_api_initialization.py +++ b/deckhand/tests/unit/control/test_api_initialization.py @@ -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)) diff --git a/entrypoint.sh b/entrypoint.sh index 20201301..f0a9cea0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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