fix: start the services from the virtual environment instead of through uv #196

Merged
Michiel-Beijen merged 1 commit from Michiel-Beijen/intranet:fix/services-use-existing-venv into main 2026-11-15 21:15:56 +01:00

Follow-up to #195, which did the same for the cron scripts.

What

Both unit files in deploy/ started the service with uv run. They now start gunicorn and daphne directly from .venv/bin. The two UV_* settings in the gunicorn unit are removed, because nothing reads them any more.

Why

uv run syncs the environment before it starts the program. The services run as www-data, with a different uv cache than the deployment uses, so every restart could rebuild parts of .venv under a second account. After this change the deployment (rollout-prod.sh) is the only thing that builds the environment.

Behaviour change

A service restart can no longer repair a broken or missing .venv. If the deployment failed halfway, the services fail to start until the deployment is rerun.

Installing

Merging does not change the running services: the unit files are copied to the server by hand. After the merge has deployed:

sudo cp deploy/crm-gunicorn.service deploy/crm-daphne.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl restart crm-daphne.service crm-gunicorn.service

The installed units on the server are currently identical to the old versions in this repository.

Testing

Locally, started both programs straight from .venv/bin with an empty environment (no activation, no uv); both served the front page with HTTP 200. Not tested under systemd.

Follow-up to #195, which did the same for the cron scripts. ## What Both unit files in `deploy/` started the service with `uv run`. They now start `gunicorn` and `daphne` directly from `.venv/bin`. The two `UV_*` settings in the gunicorn unit are removed, because nothing reads them any more. ## Why `uv run` syncs the environment before it starts the program. The services run as `www-data`, with a different uv cache than the deployment uses, so every restart could rebuild parts of `.venv` under a second account. After this change the deployment (`rollout-prod.sh`) is the only thing that builds the environment. ## Behaviour change A service restart can no longer repair a broken or missing `.venv`. If the deployment failed halfway, the services fail to start until the deployment is rerun. ## Installing Merging does not change the running services: the unit files are copied to the server by hand. After the merge has deployed: ``` sudo cp deploy/crm-gunicorn.service deploy/crm-daphne.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl restart crm-daphne.service crm-gunicorn.service ``` The installed units on the server are currently identical to the old versions in this repository. ## Testing Locally, started both programs straight from `.venv/bin` with an empty environment (no activation, no uv); both served the front page with HTTP 200. Not tested under systemd.
fix: start the services from the virtual environment instead of through uv
All checks were successful
Verify Pull Request / tests (pull_request) Successful in 3m1s
46e15ec07c
'uv run' syncs the environment before starting, as the service user
(www-data) and with its own cache directory. The deployment already builds
the environment, so start gunicorn and daphne directly from .venv/bin and
drop the uv cache settings that are no longer used.
Michiel-Beijen deleted branch fix/services-use-existing-venv 2026-11-15 21:15:56 +01:00
Sign in to join this conversation.
No reviewers
No labels
Draft
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
msl/intranet!196
No description provided.