-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
42 lines (28 loc) · 801 Bytes
/
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
import atexit
import signal
import sys
import sentry # noqa
import settings
from flask_app import app
from indexer import Indexer
indexer = Indexer()
threads = []
def signal_handler(sig, frame):
print("You pressed Ctrl+C!")
print("Waiting for %s threads" % len(threads))
for t in threads:
t.do_run = False
t.join()
sys.exit(0)
def interrupt():
signal_handler(None, None)
def create_indexer():
# thread = Thread(name="Indexer started", target=indexer.start)
# threads.append(thread)
# thread.start()
signal.signal(signal.SIGINT, signal_handler)
atexit.register(interrupt)
return app
indexer = create_indexer()
if __name__ == "__main__":
indexer.run(host=settings.API_HOST, port=settings.API_PORT, debug=settings.API_DEBUG)