File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ def main() -> None:
6161 if args .dump_configuration :
6262 dump_configuration (configuration .configuration )
6363 else :
64- start_uvicorn ()
64+ start_uvicorn (configuration . service_configuration )
6565 logger .info ("Lightspeed stack finished" )
6666
6767
Original file line number Diff line number Diff line change 44
55import uvicorn
66
7+ from models .config import ServiceConfiguration
8+
79logger : logging .Logger = logging .getLogger (__name__ )
810
911
10- def start_uvicorn () -> None :
12+ def start_uvicorn (configuration : ServiceConfiguration ) -> None :
1113 """Start Uvicorn-based REST API service."""
1214 logger .info ("Starting Uvicorn" )
1315
14- host = "localhost"
15- port = 8080
16- workers = 1
1716 log_level = logging .INFO
1817
1918 uvicorn .run (
2019 "app.main:app" ,
21- host = host ,
22- port = port ,
23- workers = workers ,
20+ host = configuration . host ,
21+ port = configuration . port ,
22+ workers = configuration . workers ,
2423 log_level = log_level ,
2524 use_colors = True ,
2625 access_log = True ,
Original file line number Diff line number Diff line change 33from unittest .mock import patch
44
55
6+ from models .config import ServiceConfiguration
67from runners .uvicorn import start_uvicorn
78
89
910def test_start_uvicorn () -> None :
1011 """Test the function to start Uvicorn server."""
12+ configuration = ServiceConfiguration (host = "localhost" , port = 8080 , workers = 1 )
13+
1114 # don't start real Uvicorn server
1215 with patch ("uvicorn.run" ) as mocked_run :
13- start_uvicorn ()
16+ start_uvicorn (configuration )
1417 mocked_run .assert_called_once_with (
1518 "app.main:app" ,
1619 host = "localhost" ,
You can’t perform that action at this time.
0 commit comments