forked from hiroshil/MDM_server-fork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
49 lines (45 loc) · 1.3 KB
/
app.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
import os
import sys
import logging
import signal
import logConfig
from appSettings import app_settings
from task import TaskManager
from worker import WorkerManager
import hideclick
import web
logging.getLogger('App')
HOST = ('127.0.0.1', 12000)
worker_mgr = None
def menu():
print("""
Wellcome MDM > Meo Download Manager <
""")
print(' Access dashboard: http://%s:%s/' % (HOST[0], HOST[1]))
for file in os.listdir(os.path.join(os.getcwd(), 'data', 'UserScripts')):
if file.endswith('.user.js'):
print(""" To install code go to: http://%s:%s/userscripts/%s
""" % (HOST[0], HOST[1], file))
def signalHander(sig, frame):
print('Wait for cleanup...')
if worker_mgr:
worker_mgr.shutdown()
print('Stop program!')
sys.exit(0)
def main():
global worker_mgr
os.environ['loadingstop'] = '1'
os.environ['WERKZEUG_RUN_MAIN'] = 'false'
signal.signal(signal.SIGINT, signalHander)
app_settings.checkArgs()
app_settings.load()
logConfig.setup(app_settings.log_level)
task_mgr = TaskManager()
worker_mgr = WorkerManager(task_mgr)
worker_mgr.load_task_unfinished()
worker_mgr.start()
os.system('cls')
menu()
web.run(task_mgr, HOST[0], HOST[1])
if __name__ == '__main__':
main()