-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (23 loc) · 841 Bytes
/
Copy pathapp.py
File metadata and controls
28 lines (23 loc) · 841 Bytes
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
import threading
from src import config, app
from src.consumer import RabbitMQConsumer
consumer = RabbitMQConsumer()
def start_consumer():
consumer.start()
if __name__ == "__main__":
app.logger.info("Server started running at {}:{}".format(config.HOST, config.PORT))
# Start the consumer in a separate thread
consumer_thread = threading.Thread(target=start_consumer)
consumer_thread.start()
with app.app_context():
try:
app.run(
host=config.HOST,
port=config.PORT,
debug=config.DEBUG,
# ssl_context="adhoc"
)
finally:
app.logger.info("Server terminated at {}:{}".format(config.HOST, config.PORT))
consumer.stop()
consumer_thread.join()