Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
feat(dev): add script to run auto-reloading celery workers
Browse files Browse the repository at this point in the history
The single script starts celery scheduler, analytics worker and alerts
worker. It also stops all 3 of them on doing ctrl-c.

Added a new dependency `watchdog` to watch files and restart workers
when there's a code change.

TODO: have a flag to disable auto-reload.
  • Loading branch information
Samyak2 committed Feb 9, 2022
1 parent cd484af commit e5b94cc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dev_workers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh

source .venv/bin/activate

(trap 'kill 0' SIGINT EXIT; \
./scripts/celery/dev_scheduler.sh & \
./scripts/celery/dev_worker-analytics.sh & \
./scripts/celery/dev_worker-alerts.sh )
4 changes: 4 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ flake8-docstrings==1.6.0
flake8-isort==4.0.0
isort==5.8.0
pep8-naming==0.11.1

# for auto-reloading celery workers when code changes
watchdog[watchmedo]~=2.1.6

2 changes: 2 additions & 0 deletions scripts/celery/dev_scheduler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- celery -A run.celery beat --loglevel=DEBUG
2 changes: 2 additions & 0 deletions scripts/celery/dev_worker-alerts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q alerts
2 changes: 2 additions & 0 deletions scripts/celery/dev_worker-analytics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
watchmedo auto-restart --directory=./ --pattern=*.py --recursive -- celery -A run.celery worker --loglevel=INFO --concurrency=2 -P processes -Q anomaly-rca

0 comments on commit e5b94cc

Please sign in to comment.