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