Commit 28452e2b authored by Leo Pound Singer's avatar Leo Pound Singer
Browse files

WIP: Start, stop, and supervise gwcelery with monit

This is an alternative to !343.
parent 72bd5204
Pipeline #51910 passed with stages
in 1 minute and 55 seconds
{% set LOG_DIR %}{{XDG_CONFIG_HOME}}/log/gwcelery{% endset -%}
{% set RUN_DIR %}{{XDG_RUNTIME_DIR}}/gwcelery{% endset -%}
{% set STATE_DIR %}{{XDG_CONFIG_HOME}}/gwcelery{% endset -%}
check directory log-dir path "{{LOG_DIR}}"
start program = "/bin/mkdir -p {{LOG_DIR}}"
check directory run-dir path "{{RUN_DIR}}"
start program = "/bin/mkdir -p {{RUN_DIR}}"
check directory state-dir path "{{STATE_DIR}}"
start program = "/bin/mkdir -p {{STATE_DIR}}"
{%- macro PIDFILE_PROCESS(name) %}
{% set PIDFILE %}{{RUN_DIR}}/{% endset %}
check process {{name}} with pidfile "{{PIDFILE}}"
stop program = "/bin/sh -c 'kill $(cat {{PIDFILE}})'"
{%- endmacro -%}
{%- macro ENV() %}
/usr/bin/env CELERY_BROKER_URL=redis+socket://{{RUN_DIR}}/redis.sock
{%- endmacro -%}
{% call(PIDFILE) PIDFILE_PROCESS('redis') %}
depends on log-dir, run-dir
start program = "
--daemonize yes
--pidfile {{PIDFILE}}
--unixsocket {{RUN_DIR}}/redis.sock
--unixsocketperm 700
--client-output-buffer-limit normal 0 0 0
--client-output-buffer-limit replica 256mb 64mb 60
--client-output-buffer-limit pubsub 256mb 64mb 60
--logfile {{LOG_DIR}}/redis.log
--port 0"
{% endcall %}
{% call(PIDFILE) PIDFILE_PROCESS('beat') %}
depends on log-dir, run-dir, state-dir, redis
start program = "
gwcelery beat
--pidfile {{PIDFILE}}
--logfile {{LOG_DIR}}/beat.log
--loglevel ERROR
--schedule {{STATE_DIR}}/beat"
{% endcall %}
{% call(PIDFILE) PIDFILE_PROCESS('flask') %}
depends on log-dir, run-dir, redis
start program = "
-v -a -e {{LOG_DIR}}/flask.log
-p {{PIDFILE}}
gwcelery flask run --with-threads --host"
{% endcall %}
{% call(PIDFILE) PIDFILE_PROCESS('flower') %}
depends on log-dir, run-dir, redis
start program = "
-v -a -e {{LOG_DIR}}/flower.log
-p {{PIDFILE}}
gwcelery flower"
{% endcall %}
{%- macro WORKER(queue, args='') %}
check process {{queue}} with pidfile "{{RUN_DIR}}/{{queue}}.pid"
depends on log-dir, run-dir, redis
start program = "
gwcelery multi start
{{queue}} {{args}}
--loglevel=info --queues=%n --hostname=%n
restart program = "
gwcelery multi restart
{{queue}} {{args}}
--loglevel=info --queues=%n --hostname=%n
stop program = "
gwcelery multi stopwait {{queue}} --pidfile={{RUN}}/"
{%- endmacro %}
{{WORKER('exttrig', '--concurrency=1')}}
{{WORKER('openmp', '--concurrency=1')}}
{{WORKER('superevent', '--concurrency=1')}}
{{WORKER('voevent', '--pool=solo')}}
set daemon 5
set httpd unixsocket {{RUN_DIR}}/monit.sock allow localhost
set log {{LOG_DIR}}/monit.log
"""Create a monitrc file for running GWCelery under the current user
import os
from celery.bin.base import Command
from ..jinja import env
class MonitrcCommand(Command):
"""Check Celery status for monitoring with Nagios."""
def run(self, **kwargs):
......@@ -48,6 +48,7 @@ python_requires = >=3.6, <3.7
celery.commands =
condor =
flask =
monitrc =
nagios =
console_scripts =
gwcelery = gwcelery:app.start
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment