-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
32 lines (30 loc) · 994 Bytes
/
start.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
from argparse import ArgumentParser
from droid import create_app, toast
from loguru import logger
import asyncio
import time
import sys
import os
# --
if __name__ == '__main__':
logger.remove()
fmt = "{line:4}| [{file}:{level:6}] > {message}"
parser = ArgumentParser(prog='Turmoid')
parser.add_argument('--mode', type=str, default='dev', help='Program running mode.')
parser.add_argument('--modules', type=str, default='mod', help='Modules path.')
# --
args = parser.parse_args()
if args.mode == 'live':
toast('Production mode.')
if not os.fork():
logger.add('logs/turmoid.log', format=fmt)
logger.info('Started at: {}', time.time())
app = create_app(args.modules)
asyncio.run(app.run())
else:
toast('Child started.')
else:
toast('Development mode.')
logger.add(sys.stdout, format=fmt)
app = create_app(args.modules)
asyncio.run(app.run())