diff --git a/uwsgi-python/handlers/main.yml b/uwsgi-python/handlers/main.yml index 28c6b49e21c4b28e5777a20e6a72e553e58198da..90c3d24201922b224921c2ad41060256e2ca51e4 100644 --- a/uwsgi-python/handlers/main.yml +++ b/uwsgi-python/handlers/main.yml @@ -93,8 +93,13 @@ - name: restart uwsgi instance vampir-mitglieder service: name="uwsgi@vampir-mitglieder" state=restarted -- name: restart uwsgi instance alumnigraph +- name: restart uwsgi instance alumnigraph uwsgi service: name="uwsgi@alumnigraph" state=restarted + listen: "restart uwsgi instance alumnigraph" + +- name: restart uwsgi instance alumnigraph celery + service: name="alumnigraph-celery" state=restarted + listen: "restart uwsgi instance alumnigraph" - name: restart uwsgi instance ak-tracker service: name="uwsgi@ak-tracker" state=restarted diff --git a/uwsgi-python/tasks/apps/alumnigraph.yml b/uwsgi-python/tasks/apps/alumnigraph.yml index a3ec7ee5b6a96adf3223e28676595616dae56610..29bae3c7de2d4a2fc97fa53a3d98bdf941e9f1ab 100644 --- a/uwsgi-python/tasks/apps/alumnigraph.yml +++ b/uwsgi-python/tasks/apps/alumnigraph.yml @@ -19,6 +19,25 @@ notify: - "restart uwsgi instance {{app.instance}}" +- name: ensure the celery unit file exists + template: + src: apps/alumnigraph-celery.service.j2 + dest: "/etc/systemd/system/{{ app_name }}-celery.service" + owner: root + group: root + mode: '0644' + notify: + - reload systemd service files + - "restart uwsgi instance {{app.instance}}" + +- meta: flush_handlers + +- name: ensure the celery service is enabled + service: + name: "{{app_name}}-celery" + enabled: true + state: started + - name: ensure the folder from above is not present anymore file: path: "{{app_path}}/.ansible" diff --git a/uwsgi-python/templates/apps/alumnigraph-celery.service.j2 b/uwsgi-python/templates/apps/alumnigraph-celery.service.j2 new file mode 100644 index 0000000000000000000000000000000000000000..5d0fc6887a6edb0215a08999510a7a2e9480be46 --- /dev/null +++ b/uwsgi-python/templates/apps/alumnigraph-celery.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description={{ app_name }}-Celery +After=network.target + +[Service] +User={{ app_user }} +Group={{ app_group }} +WorkingDirectory={{ app_path }} +Environment=VIRTUAL_ENV="{{ app_path }}" +ExecStart={{ app_venv }}/bin/celery -A server.celery worker --loglevel=DEBUG --concurrency={{ alumni_graph_celery_concurrency }} +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/uwsgi-python/templates/apps/alumnigraph.j2 b/uwsgi-python/templates/apps/alumnigraph.j2 index 31ba5f45a0a28cde24a55bfaf7a065fddebc0b48..01938be2dfa1663080fbf90387f6dc249553b69b 100644 --- a/uwsgi-python/templates/apps/alumnigraph.j2 +++ b/uwsgi-python/templates/apps/alumnigraph.j2 @@ -23,3 +23,4 @@ SEND_INVITATIONS = {{ alumni_graph_send_invitation }} SENTRY_URL = "{{ alumni_graph_sentry_url }}" BABEL_DEFAULT_LOCALE = "DE" +CELERY_BROKER_URL = {{ alumni_graph_celery_broker }} diff --git a/uwsgi-python/vars/alumnigraph.yml b/uwsgi-python/vars/alumnigraph.yml index 330e5135978929b062082e12ca384e9c18ffefec..c64810369b1ec9d3313cb333cb1e0482e6fb53d7 100644 --- a/uwsgi-python/vars/alumnigraph.yml +++ b/uwsgi-python/vars/alumnigraph.yml @@ -47,3 +47,6 @@ alumni_graph_sentry_url: "" # Do not define if there is no authentication needed # alumni_graph_mail_user: None # alumni_graph_mail_pass: None +# +alumni_graph_celery_broker: '"redis://localhost:6379/2"' +alumni_graph_celery_concurrency: 2