-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (49 loc) · 1.67 KB
/
Copy pathmain.py
File metadata and controls
60 lines (49 loc) · 1.67 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import sys
import threading
import logging
import uvicorn
from PySide6.QtWidgets import QApplication
from database import init_db
from gateway import app as gateway_app
from api_client import VApiClient
from desktop import MainWindow, DARK_STYLESHEET
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
handlers=[logging.StreamHandler(sys.stdout)],
)
logger = logging.getLogger("vapi-main")
def run_gateway_server():
logger.info("Starting FastAPI Gateway server on http://127.0.0.1:8000")
config = uvicorn.Config(
gateway_app,
host="127.0.0.1",
port=8000,
log_level="info",
use_colors=True,
)
server = uvicorn.Server(config)
server.run()
def main():
if "--headless" in sys.argv:
logger.info("Running in headless mode...")
init_db()
logger.info("Starting FastAPI Gateway server on http://0.0.0.0:8000")
uvicorn.run(gateway_app, host="0.0.0.0", port=8000, log_level="info", use_colors=False)
return
logger.info("Initializing database...")
init_db()
gateway_thread = threading.Thread(target=run_gateway_server, daemon=True)
gateway_thread.start()
logger.info("Launching vAPI Desktop Client...")
qt_app = QApplication(sys.argv)
qt_app.setApplicationName("vAPI Gateway")
qt_app.setOrganizationName("vAPI")
qt_app.setStyleSheet(DARK_STYLESHEET)
client = VApiClient()
window = MainWindow(client)
window.show()
logger.info("Desktop client loaded successfully.")
sys.exit(qt_app.exec())
if __name__ == "__main__":
main()