Skip to content

Commit

Permalink
[Hardening] Simple Celery options to [try] to prevent pre-forked work…
Browse files Browse the repository at this point in the history
…ers delay and hang-up
  • Loading branch information
afabiani committed Jan 12, 2021
1 parent 9c84a2d commit 87548b2
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion celery.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
nohup celery -A geonode.celery_app:app beat -l DEBUG -f /var/log/celery.log &>/dev/null &
nohup celery -A geonode.celery_app:app worker -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h -f /var/log/celery.log &>/dev/null &
nohup celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h -f /var/log/celery.log &>/dev/null &
nohup celery -A geonode.celery_app:app flower --auto_refresh=True --debug=False --broker=${BROKER_URL} --basic_auth=${ADMIN_USERNAME}:${ADMIN_PASSWORD} --address=0.0.0.0 --port=5555 &>/dev/null &
2 changes: 1 addition & 1 deletion celery_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ set -a
. ./.env_dev
set +a

celery -A geonode.celery_app:app worker -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=DEBUG --concurrency=10 -n worker1@%h
celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=DEBUG --concurrency=10 -n worker1@%h
2 changes: 1 addition & 1 deletion docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
environment:
- IS_CELERY=True
entrypoint: ["/usr/src/geonode/entrypoint.sh"]
command: "celery -A geonode.celery_app:app worker -B -E --statedb=/mnt/volumes/statics/worker.state -s /mnt/volumes/statics/celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h -f /var/log/celery.log"
command: "celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=/mnt/volumes/statics/worker.state -s /mnt/volumes/statics/celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h -f /var/log/celery.log"

# Nginx is serving django static and media files and proxies to django and geonode
geonode:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ services:
environment:
- IS_CELERY=True
entrypoint: ["/usr/src/geonode/entrypoint.sh"]
command: "celery -A geonode.celery_app:app worker -B -E --statedb=/mnt/volumes/statics/worker.state -s /mnt/volumes/statics/celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h -f /var/log/celery.log"
command: "celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=/mnt/volumes/statics/worker.state -s /mnt/volumes/statics/celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h -f /var/log/celery.log"

# Nginx is serving django static and media files and proxies to django and geonode
geonode:
Expand Down
3 changes: 3 additions & 0 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,9 @@ def get_geonode_catalogue_service():
# Allow to recover from any unknown crash.
CELERY_ACKS_LATE = ast.literal_eval(os.environ.get('CELERY_ACKS_LATE', 'True'))

# Add a ten-minutes timeout to all Celery tasks.
CELERYD_TASK_SOFT_TIME_LIMIT = 600

# Set this to False in order to run async
_EAGER_FLAG = 'False' if ASYNC_SIGNALS else 'True'
CELERY_TASK_ALWAYS_EAGER = ast.literal_eval(os.environ.get('CELERY_TASK_ALWAYS_EAGER', _EAGER_FLAG))
Expand Down
2 changes: 1 addition & 1 deletion pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def start_django(options):
sh('%s python -W ignore manage.py runserver %s %s' % (settings, bind, foreground))

if 'django_celery_beat' not in INSTALLED_APPS:
sh("{} celery -A geonode.celery_app:app worker -B -E \
sh("{} celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E \
--statedb=worker.state -s celerybeat-schedule --loglevel=DEBUG \
--concurrency=10 -n worker1@%h -f celery.log {}".format( # noqa
settings,
Expand Down
2 changes: 1 addition & 1 deletion scripts/spcgeonode/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
command: "uwsgi --chdir=/spcgeonode --module=geonode.wsgi --socket=:8000 --http=127.0.0.1:8001 --processes=5 --py-autoreload=2"
celery:
<< : *default-common-django
command: 'celery -A geonode.celery_app:app worker -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=DEBUG --concurrency=10 -n worker1@%h'
command: 'celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=DEBUG --concurrency=10 -n worker1@%h'

nginx:
image: geonode/spcgeonode:nginx-3.1
Expand Down
2 changes: 1 addition & 1 deletion scripts/spcgeonode/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ services:
celery:
<< : *default-common-django
entrypoint: []
command: 'celery -A geonode.celery_app:app worker -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h'
command: 'celery -A geonode.celery_app:app worker --without-gossip --without-mingle -Ofair -B -E --statedb=worker.state -s celerybeat-schedule --loglevel=INFO --concurrency=10 -n worker1@%h'

# Nginx is serving django static and media files and proxies to django and geonode
nginx:
Expand Down

0 comments on commit 87548b2

Please sign in to comment.