-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
44 lines (32 loc) · 965 Bytes
/
run.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
import threading
import logging
import asyncio
import signal
import time
from aiohttp import web
from multiprocessing import Process
from iamcoin.api import loop
threads = []
class ServiceExit(Exception):
pass
def service_shutdown(signum, frame):
logging.info("Received signal...")
raise ServiceExit
def start_api_server():
try:
loop.run_forever()
#web.run_app(app, port=5000)
except ServiceExit:
loop.stop()
logging.info("Stopping API thread")
if __name__ == "__main__":
logging.info("Start of the world")
signal.signal(signal.SIGTERM, service_shutdown)
signal.signal(signal.SIGINT, service_shutdown)
start_api_server()
# api_thread = threading.Thread(target=start_api_server, name="API-Thread")
# api_thread.start()
# api_process = Process(target= start_api_server, name="API-Thread")
# api_process.start()
#threads.append(api_thread)
logging.info("Adios:)")