Skip to content

Commit

Permalink
Merge pull request #27 from onaio/default-celery-directories
Browse files Browse the repository at this point in the history
Ensure default celery pid directories are present
  • Loading branch information
moshthepitt authored Sep 3, 2019
2 parents 96a4fc8 + 5ef7620 commit 4e7eb86
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,7 @@ django_celerybeat_service_name: "celerybeat-{{ django_service_name }}"
django_celeryd_opts: "--time-limit=300 --concurrency=8"
django_celeryd_log_level: "INFO"
django_celerybeat_log_level: "INFO"
django_celeryd_pid_file:
django_celery_beat_pid_file:
django_celeryd_pid_directory: "/run/celery-{{ django_system_user }}"
django_celeryd_pid_file: "{{ django_celeryd_pid_directory }}/%n.pid"
django_celery_beat_pid_directory: "/var/run/{{ django_system_user }}"
django_celery_beat_pid_file: "{{ django_celery_beat_pid_directory }}/celerybeat.pid"
13 changes: 13 additions & 0 deletions tasks/celery.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
---
- name: Ensure celery pid directories are present
file:
state: directory
owner: "{{ django_system_user }}"
group: "{{ django_system_group }}"
path: "{{ item }}"
when:
- item is defined
- item is not none
with_items:
- "{{ django_celeryd_pid_directory }}"
- "{{ django_celery_beat_pid_directory }}"

- name: Copy celeryd default script
template:
src: templates/etc/default/celeryd.j2
Expand Down
8 changes: 2 additions & 6 deletions templates/etc/default/celerybeat.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ C_FORCE_ROOT=1
CELERYBEAT_LOG_LEVEL="{{ django_celerybeat_log_level }}"
CELERYBEAT_LOG_FILE="{{ django_log_path }}/celerybeat.log"
CELERY_CREATE_DIRS=1
CELERYBEAT_SCHEDULE="/var/run/{{ django_system_user }}/celerybeat-schedule"
CELERYBEAT_STATE_DIR="/var/run/{{ django_system_user }}/celerybeat"
{% if django_celery_beat_pid_file %}
CELERYBEAT_SCHEDULE="{{ django_celery_beat_pid_directory }}/celerybeat-schedule"
CELERYBEAT_STATE_DIR="{{ django_celery_beat_pid_directory }}/celerybeat"
CELERYBEAT_PID_FILE="{{ django_celery_beat_pid_file }}"
{% else %}
CELERYBEAT_PID_FILE="/var/run/{{ django_system_user }}/celerybeat.pid"
{% endif %}
# Name of the projects settings module.
# in this case is just settings and not the full path because it will change the dir to
# the project folder first.
Expand Down
4 changes: 0 additions & 4 deletions templates/etc/default/celeryd.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ CELERY_APP="{{ django_celery_app }}"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="{{ django_log_path }}/celery-%n.log"
{% if django_celeryd_pid_file %}
CELERYD_PID_FILE="{{ django_celeryd_pid_file }}"
{% else %}
CELERYD_PID_FILE="/run/celery-{{ django_system_user }}/%n.pid"
{% endif %}

# Workers should run as an unprivileged user.
CELERYD_USER="{{ django_system_user }}"
Expand Down
1 change: 1 addition & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- uwsgi
- 'redis==2.10.6'
- 'django==1.11'
- requests
django_top_python_statements:
- import os
- from decimal import Decimal
Expand Down

0 comments on commit 4e7eb86

Please sign in to comment.