-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.py
40 lines (30 loc) · 1.04 KB
/
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
38
39
40
# Load .env file
from dotenv import load_dotenv
load_dotenv()
import asyncio
import os
import uvicorn
from threading import Thread
from cloudlink import CloudlinkServer
from supporter import Supporter
from security import background_tasks_loop
from rest_api import app as rest_api
if __name__ == "__main__":
# Create Cloudlink server
cl = CloudlinkServer()
# Create Supporter class
supporter = Supporter(cl)
cl.supporter = supporter
# Start background tasks loop
Thread(target=background_tasks_loop, daemon=True).start()
# Initialise REST API
rest_api.cl = cl
rest_api.supporter = supporter
# Start REST API
Thread(target=uvicorn.run, args=(rest_api,), kwargs={
"host": os.getenv("API_HOST", "0.0.0.0"),
"port": int(os.getenv("API_PORT", 3001)),
"root_path": os.getenv("API_ROOT", "")
}, daemon=True).start()
# Start Cloudlink server
asyncio.run(cl.run(host=os.getenv("CL3_HOST", "0.0.0.0"), port=int(os.getenv("CL3_PORT", 3000))))