2025-04-11 16:51:44 -07:00
|
|
|
import argparse
|
2025-12-21 03:30:10 -08:00
|
|
|
import asyncio
|
2025-04-13 13:56:22 -07:00
|
|
|
import logging
|
2025-12-21 03:30:10 -08:00
|
|
|
import sys
|
2025-07-24 14:43:48 -07:00
|
|
|
|
|
|
|
|
import uvicorn
|
2025-06-10 22:06:45 +07:00
|
|
|
from dotenv import load_dotenv
|
2025-07-24 14:43:48 -07:00
|
|
|
|
2025-12-21 03:30:10 -08:00
|
|
|
# Fix for Windows: psycopg requires SelectorEventLoop, not ProactorEventLoop
|
|
|
|
|
if sys.platform == "win32":
|
|
|
|
|
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
|
|
|
|
|
2025-06-10 22:12:45 +07:00
|
|
|
from app.config.uvicorn import load_uvicorn_config
|
2025-04-13 13:56:22 -07:00
|
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
|
level=logging.INFO,
|
2025-06-10 22:12:45 +07:00
|
|
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
|
|
|
datefmt="%Y-%m-%d %H:%M:%S",
|
2025-04-13 13:56:22 -07:00
|
|
|
)
|
2025-03-14 18:53:14 -07:00
|
|
|
|
2025-06-10 22:06:45 +07:00
|
|
|
load_dotenv()
|
|
|
|
|
|
2025-03-14 18:53:14 -07:00
|
|
|
if __name__ == "__main__":
|
2025-06-10 22:12:45 +07:00
|
|
|
parser = argparse.ArgumentParser(description="Run the SurfSense application")
|
|
|
|
|
parser.add_argument("--reload", action="store_true", help="Enable hot reloading")
|
2025-04-11 16:51:44 -07:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
2025-06-10 22:52:19 +07:00
|
|
|
config_kwargs = load_uvicorn_config(args)
|
2025-06-10 23:12:59 +07:00
|
|
|
config = uvicorn.Config(**config_kwargs)
|
|
|
|
|
server = uvicorn.Server(config)
|
|
|
|
|
|
2026-02-26 18:24:57 -08:00
|
|
|
if sys.platform == "win32":
|
|
|
|
|
asyncio.run(server.serve(), loop_factory=asyncio.SelectorEventLoop)
|
|
|
|
|
else:
|
|
|
|
|
server.run()
|