-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
38 lines (26 loc) · 811 Bytes
/
main.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
import os
import logging
import uvicorn
import asyncio
from dotenv import load_dotenv
load_dotenv()
from oscm.utils import GracefulShutdown
debug = os.environ.get('APP_DEBUG', '') == "true"
if debug:
import coloredlogs
coloredlogs.install(level='DEBUG')
loop = asyncio.get_event_loop()
log = logging.getLogger()
def shutdown():
from oscm.routes import vpn
loop.run_until_complete(vpn.stop())
if __name__ == '__main__':
log.info("Starting up..")
try:
with GracefulShutdown(before_shutdown=shutdown):
loop = asyncio.get_event_loop()
uvicorn.run("oscm:app", host='0.0.0.0', port=8080, debug=debug, reload=debug, timeout_keep_alive=120,
access_log=False)
except Exception as e:
log.exception(e)
exit(e)