-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
MIND.py
65 lines (49 loc) · 1.47 KB
/
MIND.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
"""
The main file where MIND is started from
"""
from sys import argv
from backend.db import setup_db, setup_db_location
from backend.helpers import check_python_version
from backend.logging import LOGGER, setup_logging
from backend.reminders import ReminderHandler
from backend.server import SERVER, handle_flags
from backend.settings import get_setting
#=============================
# WARNING:
# These settings have moved into the admin panel. Their current value has been
# taken over. The values will from now on be ignored, and the variables will
# be deleted next version.
HOST = '0.0.0.0'
PORT = '8080'
URL_PREFIX = '' # Must either be empty or start with '/' e.g. '/mind'
#=============================
def MIND() -> None:
"""The main function of MIND
"""
setup_logging()
LOGGER.info('Starting up MIND')
if not check_python_version():
exit(1)
flag = argv[1] if len(argv) > 1 else None
handle_flags(flag)
setup_db_location()
SERVER.create_app()
reminder_handler = ReminderHandler(SERVER.app.app_context)
with SERVER.app.app_context():
setup_db()
host = get_setting("host")
port = get_setting("port")
url_prefix = get_setting("url_prefix")
SERVER.set_url_prefix(url_prefix)
reminder_handler.find_next_reminder()
# =================
SERVER.run(host, port)
# =================
reminder_handler.stop_handling()
if SERVER.do_restart:
SERVER.handle_restart(flag)
return
if __name__ == "__main__":
MIND()