mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Reworking how Sanic is run for upgraded Sanic version
This commit is contained in:
parent
bdf5e0856f
commit
399b17ce4e
5 changed files with 15 additions and 0 deletions
|
|
@ -50,6 +50,10 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: docker/api/Dockerfile
|
||||
environment:
|
||||
# Sanic 25.x wants 'spawn' but our code uses 'fork' for multiprocessing.
|
||||
# This tells Sanic to accept the existing start method.
|
||||
- SANIC_START_METHOD_SET=1
|
||||
volumes:
|
||||
- './main.py:/opt/wrolpi/main.py'
|
||||
- './wrolpi:/opt/wrolpi/wrolpi'
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ Conflicts=wrolpi-api.service
|
|||
|
||||
[Service]
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
# Sanic 25.x wants 'spawn' but our code uses 'fork' for multiprocessing.
|
||||
Environment=SANIC_START_METHOD_SET=1
|
||||
ExecStart=/opt/wrolpi/venv/bin/python -m sanic main:api_app --host 0.0.0.0 --port 8081 -w 2 --reload --debug
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Group=wrolpi
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ Conflicts=wrolpi-api-dev.service
|
|||
|
||||
[Service]
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
# Sanic 25.x wants 'spawn' but our code uses 'fork' for multiprocessing.
|
||||
Environment=SANIC_START_METHOD_SET=1
|
||||
ExecStart=/opt/wrolpi/venv/bin/python -O -m sanic main:api_app --host 0.0.0.0 --port 8081 -w 5
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Group=wrolpi
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ libzim==3.5.0
|
|||
mock==5.1.0
|
||||
psutil==6.0.0
|
||||
psycopg2-binary==2.9.9
|
||||
pydantic>=2.0.0
|
||||
pypdf==6.4.0
|
||||
pytest-asyncio==0.24.0
|
||||
pytest-xdist==3.5.0
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ from wrolpi.vars import PYTEST
|
|||
|
||||
logger = logger.getChild(__name__)
|
||||
|
||||
# Sanic 25.x wants to use 'spawn' as the multiprocessing start method, but our code
|
||||
# uses 'fork' extensively (via multiprocessing.Manager, Event, Queue, etc.).
|
||||
# Tell Sanic to use 'fork' and that the start method is already configured.
|
||||
Sanic.start_method = "fork"
|
||||
Sanic.START_METHOD_SET = True
|
||||
|
||||
# The only Sanic App, this is imported all over.
|
||||
api_app = Sanic(name='api_app', log_config=LOGGING_CONFIG)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue