@@ -33,8 +33,6 @@ def __init__(self, config: UvicornConfig, server: Server):
33
33
self ._shutdown_event = asyncio .Event ()
34
34
self ._should_exit = False
35
35
36
-
37
-
38
36
async def serve (self ) -> None :
39
37
"""Start the uvicorn server and handle shutdown gracefully."""
40
38
logger .debug (f"Starting server on { self .host } :{ self .port } " )
@@ -247,12 +245,12 @@ def serve(
247
245
ollama_url : Optional [str ],
248
246
model_base_path : Optional [str ],
249
247
embedding_model : Optional [str ],
248
+ db_path : Optional [str ],
250
249
certs_dir : Optional [str ],
251
250
ca_cert : Optional [str ],
252
251
ca_key : Optional [str ],
253
252
server_cert : Optional [str ],
254
253
server_key : Optional [str ],
255
- db_path : Optional [str ],
256
254
) -> None :
257
255
"""Start the codegate server."""
258
256
try :
@@ -287,7 +285,7 @@ def serve(
287
285
db_path = db_path ,
288
286
)
289
287
290
- init_db_sync ()
288
+ init_db_sync (cfg . db_path )
291
289
292
290
293
291
# Check certificates and create CA if necessary
@@ -341,11 +339,6 @@ async def run_servers(cfg: Config, app) -> None:
341
339
},
342
340
)
343
341
344
- init_db_sync (cfg .db_path )
345
- app = init_app ()
346
-
347
- import uvicorn
348
-
349
342
# Create Uvicorn configuration
350
343
uvicorn_config = UvicornConfig (
351
344
app ,
@@ -359,17 +352,12 @@ async def run_servers(cfg: Config, app) -> None:
359
352
360
353
# Initialize CopilotProvider and call run_proxy_server
361
354
copilot_provider = CopilotProvider (cfg )
362
- # copilot_provider.run_proxy_server(cfg.proxy_port)
363
-
364
355
365
356
tasks = [
366
357
asyncio .create_task (server .serve ()), # Uvicorn server
367
358
asyncio .create_task (copilot_provider .run_proxy_server ()) # Proxy server
368
359
]
369
360
370
- # Create and start Uvicorn server
371
- # server = UvicornServer(uvicorn_config, Server(config=uvicorn_config))
372
-
373
361
try :
374
362
await asyncio .gather (* tasks )
375
363
except asyncio .CancelledError :
@@ -387,15 +375,6 @@ async def run_servers(cfg: Config, app) -> None:
387
375
except asyncio .CancelledError :
388
376
pass
389
377
390
-
391
- # Set up signal handlers
392
- # loop = asyncio.get_running_loop()
393
- # for sig in (signal.SIGTERM, signal.SIGINT):
394
- # loop.add_signal_handler(sig, lambda: asyncio.create_task(server.cleanup()))
395
-
396
- # # Start server
397
- # await server.serve()
398
-
399
378
except Exception as e :
400
379
logger .exception ("Error running servers" )
401
380
raise e
@@ -422,11 +401,9 @@ def restore_backup(backup_path: Path, backup_name: str) -> None:
422
401
click .echo (f"Error restoring backup: { e } " , err = True )
423
402
sys .exit (1 )
424
403
425
-
426
404
def main () -> None :
427
405
"""Main entry point for the CLI."""
428
406
cli ()
429
407
430
-
431
408
if __name__ == "__main__" :
432
409
main ()
0 commit comments