changes to run configuration and virtual command model
This commit is contained in:
@@ -9,7 +9,7 @@ import threading
|
||||
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
|
||||
from backend import app, db
|
||||
from backend import app, db, main_logger
|
||||
from backend.cron import get_default_scheduler, add_default_jobs, async_permanent_cron_recorder_checker
|
||||
from backend.models import *
|
||||
from backend.models import room_model, recorder_model, RecorderCommand, Recorder
|
||||
@@ -34,8 +34,9 @@ def _create_and_start_default_scheduler():
|
||||
return scheduler
|
||||
|
||||
|
||||
def main():
|
||||
def run():
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
print("starting ...")
|
||||
|
||||
# db.drop_all()
|
||||
# db.create_all()
|
||||
@@ -46,25 +47,6 @@ def main():
|
||||
create_default_recorders()
|
||||
add_test_recorder()
|
||||
|
||||
print(app.config.get("SERVER_NAME", None))
|
||||
|
||||
if app.config.get("USE_SSL", False):
|
||||
try:
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
||||
context.load_cert_chain(app.config.get("CERT", 'cert.pem'), app.config.get("KEY", 'key.pem'))
|
||||
print("using ssl context!")
|
||||
app.run(debug=True, ssl_context=context, threaded=True,
|
||||
#host="0.0.0.0",
|
||||
host=app.config.get("HOST", "0.0.0.0"),
|
||||
port=app.config.get("PORT", 5443)
|
||||
)
|
||||
except FileNotFoundError:
|
||||
print("Could not find cert/key.pem!")
|
||||
app.run(debug=True, threaded=True,
|
||||
host=app.config.get("HOST", None),
|
||||
port=app.config.get("PORT", 5443)
|
||||
)
|
||||
|
||||
try:
|
||||
db.create_all()
|
||||
except Exception as e:
|
||||
@@ -73,12 +55,48 @@ def main():
|
||||
scheduler = _create_and_start_default_scheduler()
|
||||
# _start_initial_recorder_state_update(run_in_thread=False)
|
||||
|
||||
print("Server Name: {}".format(app.config.get("SERVER_NAME", None)))
|
||||
|
||||
wsb = WebSocketBase()
|
||||
print("running websocket...(replaces normal app.run()")
|
||||
wsb.start_websocket(debug=True, host="0.0.0.0")
|
||||
|
||||
if app.config.get("USE_SSL", False):
|
||||
try:
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
||||
context.load_cert_chain(app.config.get("CERT", 'cert.pem'), app.config.get("KEY", 'key.pem'))
|
||||
print("using ssl context!")
|
||||
#app.run(debug=True, ssl_context=context, threaded=True,
|
||||
# host=app.config.get("HOST", "0.0.0.0"),
|
||||
# port=app.config.get("PORT", 5443)
|
||||
# )
|
||||
print("running websocket...(replaces normal app.run()")
|
||||
|
||||
wsb.start_websocket(debug=app.config.get("DEBUG", False),
|
||||
host=app.config.get("HOST", "0.0.0.0"),
|
||||
port=app.config.get("PORT", 5443),
|
||||
ssl_context=context
|
||||
)
|
||||
except FileNotFoundError:
|
||||
print("Could not find cert/key.pem!")
|
||||
#app.run(debug=True, threaded=True,
|
||||
# host=app.config.get("HOST", None),
|
||||
# port=app.config.get("PORT", 5443)
|
||||
# )
|
||||
print("running websocket...(replaces normal app.run()")
|
||||
wsb.start_websocket(debug=app.config.get("DEBUG", False),
|
||||
host=app.config.get("HOST", "0.0.0.0"),
|
||||
port=app.config.get("PORT", 5443)
|
||||
)
|
||||
|
||||
else:
|
||||
print("running websocket...(replaces normal app.run()")
|
||||
wsb.start_websocket(debug=app.config.get("DEBUG", False),
|
||||
host=app.config.get("HOST", "0.0.0.0"),
|
||||
port=app.config.get("PORT", 5443)
|
||||
)
|
||||
# print("running web app...")
|
||||
# app.run(debug=True, host="0.0.0.0", threaded=True)
|
||||
wsb.send_test_msg()
|
||||
print("running!")
|
||||
|
||||
while True:
|
||||
user_in = input("Type >exit< to quit.")
|
||||
@@ -90,4 +108,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
run()
|
||||
|
||||
Reference in New Issue
Block a user