File tree Expand file tree Collapse file tree
system/usr/lib/systemd/system Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ if [ -d "/tmp/services/ui" ]; then
354354export PYTHONPATH="${PYTHONPATH:-/usr/lib/python3/site-packages}"
355355exec gunicorn \
356356 --bind "${BIND_ADDR:-127.0.0.1:8480}" \
357- --workers "${GUNICORN_WORKERS:-2 }" \
357+ --workers "${GUNICORN_WORKERS:-1 }" \
358358 --threads "${GUNICORN_THREADS:-4}" \
359359 --timeout "${GUNICORN_TIMEOUT:-60}" \
360360 --graceful-timeout 15 \
@@ -393,6 +393,8 @@ if [ ! -f /var/lib/secure-ai/.diffusion-ready ]; then
393393 exit 1
394394fi
395395source /var/lib/secure-ai/diffusion-venv/bin/activate
396+ export LANG="${LANG:-C.UTF-8}"
397+ export LC_ALL="${LC_ALL:-C.UTF-8}"
396398export PYTHONPATH="/opt/secure-ai/services/diffusion-worker:${PYTHONPATH:-}"
397399exec gunicorn \
398400 --chdir /opt/secure-ai/services/diffusion-worker \
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Environment=SECURE_AI_ROOT=/var/lib/secure-ai
2020Environment =AUTH_DATA_DIR =/var/lib/secure-ai/auth
2121Environment =AUDIT_LOG_PATH =/var/lib/secure-ai/logs/ui-audit.jsonl
2222Environment =SERVICE_TOKEN_PATH =/run/secure-ai/service-token
23+ Environment =GUNICORN_WORKERS =1
2324
2425# Filesystem isolation
2526DynamicUser =yes
Original file line number Diff line number Diff line change 1818
1919REPO_ROOT = Path (__file__ ).resolve ().parent .parent
2020UNITS_DIR = REPO_ROOT / "files" / "system" / "usr" / "lib" / "systemd" / "system"
21+ BUILD_SCRIPT = REPO_ROOT / "files" / "scripts" / "build-services.sh"
2122
2223# Services being migrated to Gunicorn (agent excluded)
2324GUNICORN_SERVICES = {
@@ -110,6 +111,23 @@ def test_agent_not_using_gunicorn(self):
110111 "Agent service should NOT use gunicorn (keeps make_server)"
111112
112113
114+ class TestOsVmGunicornRuntimeDefaults :
115+ """OS and VM images should inherit the same stable runtime defaults as sandbox."""
116+
117+ def test_ui_unit_forces_single_worker (self ):
118+ content = _read_unit ("secure-ai-ui.service" )
119+ assert "Environment=GUNICORN_WORKERS=1" in content
120+
121+ def test_ui_wrapper_defaults_to_single_worker (self ):
122+ content = BUILD_SCRIPT .read_text (encoding = "utf-8" )
123+ assert '--workers "${GUNICORN_WORKERS:-1}"' in content
124+
125+ def test_diffusion_wrapper_sets_utf8_locale (self ):
126+ content = BUILD_SCRIPT .read_text (encoding = "utf-8" )
127+ assert 'export LANG="${LANG:-C.UTF-8}"' in content
128+ assert 'export LC_ALL="${LC_ALL:-C.UTF-8}"' in content
129+
130+
113131class TestModuleExportsApp :
114132 """Each Flask service module must export 'app' at module level for WSGI import."""
115133
You can’t perform that action at this time.
0 commit comments