Commit 46cd8e0a authored by David Trattnig's avatar David Trattnig
Browse files

Separated db creation from running engine. #58

parent 72b07356
......@@ -28,8 +28,6 @@ import signal
import logging
import subprocess
import time
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
......@@ -77,14 +75,9 @@ class EngineRunner:
def run(self, start_lqs, lqs_debug_flags):
"""
Starts Engine Core.
"""
from src.scheduling.models import AuraDatabaseModel
"""
from src.core.engine import Engine
# Check if the database has to be re-) created
if self.config.get("recreate_db") is not None:
AuraDatabaseModel.recreate_db()
if start_lqs:
runner.run_lqs(lqs_debug_flags)
else:
......@@ -136,6 +129,15 @@ class EngineRunner:
def recreate_db(self):
"""
Initializes the database and deletes any existing content.
"""
from src.scheduling.models import AuraDatabaseModel
AuraDatabaseModel.recreate_db()
def exit_gracefully(self, signum, frame):
"""
Shutdown of the engine. Also terminates the Liquidsoap thread.
......@@ -173,7 +175,8 @@ if __name__ == "__main__":
if "--use-test-data" in sys.argv:
runner.config.set("use_test_data", True)
if "--recreate-database" in sys.argv:
runner.config.set("recreate_db", True)
runner.recreate_db()
sys.exit(0)
if lqs_cmd:
print(runner.get_lqs_cmd(True, True))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment