fix: stop the cron scripts from rebuilding the virtual environment #195
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Michiel-Beijen/intranet:fix/cron-use-existing-venv"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The deployment of #192 failed on a permission error in the shared uv cache. The cause is that several accounts each build the same
.venv, and the cron scripts are one of them.The hourly, nightly, weekly and monthly scripts ran
uv venv --allow-existinganduv run. Under the account that runs cron this:.venv/bin/pythonat a Python in that user's home directory, every hour;Change
The five scripts now only activate the environment that
rollout-prod.shbuilt and runpython manage.py, exactly asscripts/cron-5minutely.shalready did. They no longer call uv, so they read the environment and write nothing, whichever user runs them.Files:
cron-midnight.sh,cron-weekly.sh,cron-pre-monthly.sh,cron-monthly.sh,scripts/cron-hourly.sh.Behaviour change
A cron job can no longer repair a missing or outdated environment. The deployment is now the only place that builds it. Each script still starts with a
manage.py versioncheck and stops if the environment is broken.Testing
scripts/cron-hourly.shrun locally against a migrated database: exits 0 and leaves.venvuntouched..venvthe script stops with exit 1 and does not create one.Not in this PR
deploy/crm-gunicorn.serviceanddeploy/crm-daphne.servicestill start withuv run; they have to be installed on the server by hand, so that is a separate change.scripts/check-users-in.sh,scripts/check-users-out.shandscripts/generate-pettycash-transactions.shalso useuv run, but are not in the server's crontab.