Skip to content

Commit 3873b41

Browse files
committed
Execute uvicorn programmatically
1 parent 1735df0 commit 3873b41

File tree

7 files changed

+31
-54
lines changed

7 files changed

+31
-54
lines changed

.idea/runConfigurations/HTTP_App.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.idea/runConfigurations/Socket_io.xml

Lines changed: 0 additions & 26 deletions
This file was deleted.

docker-compose.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ services:
1616
- otel-collector
1717
command:
1818
- opentelemetry-instrument
19-
- uvicorn
20-
- http_app:create_app
21-
- --host
22-
- 0.0.0.0
23-
- --port
24-
- "8000"
25-
- --factory
26-
# Remember to disable the reloader in order to allow otel instrumentation
27-
- --reload
19+
- python
20+
- ./http_app/dev_server.py
21+
2822

2923
# Production image
3024
http:

src/http_app/__main__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import uvicorn
2+
3+
from common import AppConfig
4+
from common.logs import init_logger
5+
6+
if __name__ == "__main__":
7+
init_logger(AppConfig())
8+
uvicorn.run("http_app:create_app", factory=True, host="0.0.0.0", port=8000)

src/http_app/dev_server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import uvicorn
2+
3+
from common import AppConfig
4+
from common.logs import init_logger
5+
6+
if __name__ == "__main__":
7+
init_logger(AppConfig())
8+
uvicorn.run("http_app:create_app", factory=True, host="0.0.0.0", port=8000, reload=True)

src/socketio_app/__main__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import uvicorn
2+
3+
from common import AppConfig
4+
from common.logs import init_logger
5+
6+
if __name__ == "__main__":
7+
init_logger(AppConfig())
8+
uvicorn.run("socketio_app:create_app", factory=True, host="0.0.0.0", port=8000)

src/socketio_app/dev_server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import uvicorn
22

3+
from common import AppConfig
4+
from common.logs import init_logger
5+
36
if __name__ == "__main__":
7+
init_logger(AppConfig())
48
uvicorn.run("socketio_app:create_app", factory=True, host="0.0.0.0", port=8000, reload=True)

0 commit comments

Comments
 (0)