【问题标题】:How run a daemon of djcelery with celerycam如何使用 celerycam 运行 djcelery 的守护进程
【发布时间】:2016-02-14 06:07:06
【问题描述】:

我正在使用 django celery,我有一个与主管合作的 celery 守护程序,但我在 django 管理员中遇到问题,我看不到任务的状态, 当我输入控制台 python manage.py celerycam 时,我只能在 django 管理员中看到我的任务状态, 我如何运行 celerycam 的守护进程。

【问题讨论】:

  • 这和你用 supervisor 设置 celery 的方法一样,但是使用命令 ./manage.py celerycam
  • 我在 command=/deploy/venvs/venvSite/bin/python deploy/sites/web/manage.py celerycam 中有这个,但这没关系我在运行主管时出错

标签: django django-celery djcelery


【解决方案1】:

您可以使用您的应用程序启动您的 celerycam 守护程序,并使用 supervisorctl 一起使用 celery。

示例配置文件(/etc/supervisor/conf.d/app_name.conf):

# app config
[program:app_name]
user = www-data
directory = /var/www/app_name
command = /var/www/app_name/bin/python /var/www/app_name/bin/gunicorn agora.wsgi_server:application --bind 127.0.0.1:8022 -t 90 --workers 4 --settings='app_name.settings.production'
redirect_stderr = true
autorestart=true
stdout_logfile = /var/log/supervisor/app_name.log
stderr_logfile = /var/log/supervisor/app_name_err.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn
autostart = true
stopsignal=KILL
environment=LANG="en_US.UTF-8",LC_ALL="en_US.UTF-8",LC_LANG="en_US.UTF-8"
stopasgroup=true
killasgroup=true

# celerycam config
[program:app_name_celerycam]
user = www-data
directory = /var/www/app_name
command = /var/www/app_name/bin/python manage.py celerycam --settings='app_name.settings.production'
redirect_stderr = true
autorestart=true
stdout_logfile = /var/log/supervisor/app_name_celerycam.log
stderr_logfile = /var/log/supervisor/app_name_celerycam_err.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn
autostart = true
stopwaitsecs=5

# celery config
[program:app_name_celery]
user = www-data
directory = /var/www/app_name
command = /var/www/app_name/bin/python manage.py celeryd -l INFO -E -B  --settings='app_name.settings.production' --concurrency=1 --pidfile=/var/run/celery/app_name_celery.pid
redirect_stderr = true
autorestart=true
stdout_logfile = /var/log/supervisor/app_name_celery.log
stderr_logfile = /var/log/supervisor/app_name_celery_err.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=warn
autostart=true
stopwaitsecs=5
environment=C_FORCE_ROOT=1
stopasgroup=true
killasgroup=true

# group of our daemons
[group:app_name]
programs=app_name,app_name_celerycam,app_name_celery
priority=999

重新加载我们的配置:

supervisorctl reread

现在我们可以使用简单的命令来管理我们应用程序的所有守护进程:

supervisorctl start app_name:*
supervisorctl stop app_name:*
supervisorctl restart app_name:*
supervisorctl status app_name:*

【讨论】:

    猜你喜欢
    • 2023-03-02
    • 1970-01-01
    • 2011-12-30
    • 2023-03-17
    • 1970-01-01
    • 2017-05-27
    • 1970-01-01
    • 2022-12-12
    • 1970-01-01
    相关资源
    最近更新 更多