Commit 4331f124 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context component:

- Improved SQLAlchemy engine and database initialization
parent 61bfa554
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -44,9 +44,17 @@ def main():
    start_http_server(metrics_port)

    # Get Database Engine instance and initialize database, if needed
    LOGGER.info('Getting SQLAlchemy DB Engine...')
    db_engine = Engine.get_engine()
    if db_engine is None: return -1
    if db_engine is None:
        LOGGER.error('Unable to get SQLAlchemy DB Engine...')
        return -1

    try:
        Engine.create_database(db_engine)
    except: # pylint: disable=bare-except # pragma: no cover
        LOGGER.exception('Failed to check/create the database: {:s}'.format(str(db_engine.url)))

    rebuild_database(db_engine)

    # Get message broker instance
+0 −6
Original line number Diff line number Diff line
@@ -42,12 +42,6 @@ class Engine:
            LOGGER.exception('Failed to connect to database: {:s}'.format(str(crdb_uri)))
            return None

        try:
            Engine.create_database(engine)
        except: # pylint: disable=bare-except # pragma: no cover
            LOGGER.exception('Failed to check/create to database: {:s}'.format(str(crdb_uri)))
            return None

        return engine

    @staticmethod