Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion deploy/systemd/relaysms-publisher-rest.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ StartLimitBurst=5
Type=simple
User=relaysms
WorkingDirectory=/opt/relaysms/relaysms-publisher
# Used when .env doesn't set WORKERS.
Environment=WORKERS=4
EnvironmentFile=/opt/relaysms/relaysms-publisher/.env
Environment=OTEL_SERVICE_NAME=relaysms-publisher-rest
Environment=PATH=/opt/relaysms/relaysms-publisher/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# Fails the unit on a config error before uvicorn starts its workers.
ExecStartPre=/opt/relaysms/relaysms-publisher/venv/bin/python3 -c "import publisher.api.rest.app"
ExecStart=/opt/relaysms/relaysms-publisher/scripts/otel-wrap.sh /opt/relaysms/relaysms-publisher/venv/bin/python3 -m uvicorn publisher.api.rest.app:app --host "${HOST}" --port "${PORT}" --workers 4 --proxy-headers --forwarded-allow-ips "*"
ExecStart=/opt/relaysms/relaysms-publisher/scripts/otel-wrap.sh /opt/relaysms/relaysms-publisher/venv/bin/python3 -m uvicorn publisher.api.rest.app:app --host "${HOST}" --port "${PORT}" --workers "${WORKERS}" --proxy-headers --forwarded-allow-ips "*"
Restart=on-failure
RestartSec=5
SyslogIdentifier=relaysms-publisher-rest
Expand Down
7 changes: 7 additions & 0 deletions tests/scripts/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ def test_renders_every_unit_for_this_install(self, install, bash):
assert unit_values(rest, "ReadWritePaths") == [" ".join(app_directories(bash))]
assert "/opt/relaysms" not in "".join(units.values())

def test_rest_unit_reads_workers_with_a_default(self, install, bash):
rest = self.render(install, bash)["relaysms-publisher-rest.service"]

assert unit_values(rest, "Environment").count("WORKERS=4") == 1
(exec_start,) = unit_values(rest, "ExecStart")
assert '--workers "${WORKERS}"' in exec_start

def test_named_instance_renames_units_and_references(self, bash, install):
units = self.render(install, bash, INSTANCE_NAME="acme")

Expand Down
Loading