Skip to content

Commit 11cb361

Browse files
committed
Align OS and VM runtime defaults
1 parent 2ca3d56 commit 11cb361

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

files/scripts/build-services.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ if [ -d "/tmp/services/ui" ]; then
354354
export PYTHONPATH="${PYTHONPATH:-/usr/lib/python3/site-packages}"
355355
exec 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
394394
fi
395395
source /var/lib/secure-ai/diffusion-venv/bin/activate
396+
export LANG="${LANG:-C.UTF-8}"
397+
export LC_ALL="${LC_ALL:-C.UTF-8}"
396398
export PYTHONPATH="/opt/secure-ai/services/diffusion-worker:${PYTHONPATH:-}"
397399
exec gunicorn \
398400
--chdir /opt/secure-ai/services/diffusion-worker \

files/system/usr/lib/systemd/system/secure-ai-ui.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Environment=SECURE_AI_ROOT=/var/lib/secure-ai
2020
Environment=AUTH_DATA_DIR=/var/lib/secure-ai/auth
2121
Environment=AUDIT_LOG_PATH=/var/lib/secure-ai/logs/ui-audit.jsonl
2222
Environment=SERVICE_TOKEN_PATH=/run/secure-ai/service-token
23+
Environment=GUNICORN_WORKERS=1
2324

2425
# Filesystem isolation
2526
DynamicUser=yes

tests/test_gunicorn_config.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
REPO_ROOT = Path(__file__).resolve().parent.parent
2020
UNITS_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)
2324
GUNICORN_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+
113131
class TestModuleExportsApp:
114132
"""Each Flask service module must export 'app' at module level for WSGI import."""
115133

0 commit comments

Comments
 (0)