CDLUC3 / ezid

CDLUC3 ezid
MIT License
11 stars 4 forks source link

Deployment steps for Matomo API tracking #560

Closed sfisher closed 4 months ago

sfisher commented 5 months ago

I'm documenting this since it's a little involved to remember it all the steps for a first deploy:

CREATE TABLE kombu_queue ( id int NOT NULL AUTO_INCREMENT, name varchar(200) DEFAULT NULL, PRIMARY KEY (id), UNIQUE KEY name (name) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3


- [x] be sure settings.py  has the correct values for RW database user and start. `celery -A ezidapp worker -l INFO` starts the app
- [x] This daemon could be run under `screen` which stays alive after disconnection (or other methods) for testing until we figure out the best way to daemonize it for system.d with Ashley.
- [x] Figure out how to daemonize Celery with Ashley and get added to system.d.

Items above have been done on dev/stg at this point except for the daemonization and working with Ashley to put in systemd.

Things to consider for system.d and daemon -- https://docs.celeryq.dev/en/stable/userguide/daemonizing.html

- [x] Getting the configuration right
- [x] CeleryBeat service is needed for task cleanup, but doesn't need an external service if you aren't using it for extensive scheduling or need an external store.  Also ensure that tasks are actually getting cleaned up from the DB.

CeleryBeat can be manually started with 

`celery -A ezidapp beat -s <directory-for-local-file-for-task-tracking>`

See https://docs.celeryq.dev/en/main/userguide/periodic-tasks.html#beat-custom-schedulers and https://stackoverflow.com/questions/13147581/celery-task-clean-up-with-db-backend and https://saadali18.medium.com/setup-your-django-project-with-celery-celery-beat-and-redis-644dc8a2ac4b