-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (32 loc) · 975 Bytes
/
Copy pathmain.py
File metadata and controls
42 lines (32 loc) · 975 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Qtine - A modular chatbot framework
Entry point
"""
import sys
import os
import signal
# Ensure the project and project-local dependencies are importable.
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, PROJECT_ROOT)
sys.path.insert(0, os.path.join(PROJECT_ROOT, ".deps"))
from qtine.core.app import QtineApp
def main():
app = QtineApp(os.environ.get("QTINE_CONFIG_FILE", "config.yml"))
def shutdown_handler(sig, frame):
app.logger.info("Received shutdown signal, gracefully stopping...")
app.shutdown()
sys.exit(0)
signal.signal(signal.SIGINT, shutdown_handler)
signal.signal(signal.SIGTERM, shutdown_handler)
try:
app.run()
except KeyboardInterrupt:
app.shutdown()
except Exception as e:
app.logger.error(f"Fatal error: {e}")
app.shutdown()
sys.exit(1)
if __name__ == "__main__":
main()