gpt4 book ai didi

python - Django rq 的 Supervisord 配置不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 14:10:32 24 4
gpt4 key购买 nike

我正在关注:Putting RQ under supervisor

我的工作:

@job("default")
def send_mail(subject, body, sender, receivers, cc=None, bcc=None, content_type='plain', class_name=None):
"""Send email to users."""

*code to send mail.*

当我运行时

python manage.py rqworker

我能够使用 rq 队列执行任务。但不适用于 supervisord 配置。主管配置:

路径:/etc/supervisord/conf.d/filename.conf

[program:myworker]
; Point the command to the specific rq command you want to run.
; If you use virtualenv, be sure to point it to
; /path/to/virtualenv/bin/rq
; Also, you probably want to include a settings module to configure this
; worker. For more info on that, see http://python-rq.org/docs/workers/

command= /home/user/.virtualenvs/my_project/bin/rq worker
process_name=%(program_name)s
stdout_logfile = /var/log/my_project/redis.log

; If you want to run more than one worker instance, increase this
numprocs=1

; This is the directory from which RQ is ran. Be sure to point this to the
; directory where your source code is importable from
directory=/home/user/github_my_projects/projects/my_project

; RQ requires the TERM signal to perform a warm shutdown. If RQ does not die
; within 10 seconds, supervisor will forcefully kill it
stopsignal=TERM

; These are up to you
autostart=true
autorestart=true

最佳答案

回答我自己的问题。

下面是我在本地和开发服务器中使用的示例配置。您可以使用以下方法创建此文件:

sudo touch/etc/supervisor/conf.d/djangorq.conf

开发服务器的配置:

[program:djangorq]

command=/root/.virtualenvs/my_project/bin/rqworker
stdout_logfile=/var/log/my_project/redis.log
user=root

numprocs=1

directory=/var/www/cast-core/my_project
environment=DJANGO_CONFIGURATION=Local,DJANGO_SETTINGS_MODULE=config.local,PYTHONPATH=/var/www/projects/my_project

stopsignal=TERM

; These are up to you
autostart=true
autorestart=true

对于本地环境:

[program:myworker]
command= /home/user/.virtualenvs/my_project/bin/rqworker
stdout_logfile = /var/log/my_project/redis.log

numprocs=1

directory=/home/user/github_projects/projects/my_project
environment=DJANGO_CONFIGURATION=Local,DJANGO_SETTINGS_MODULE=config.local,PYTHONPATH=/home/user/github_projects/cast-core/my_project

user = root
stopsignal=TERM

autostart=true
autorestart=true

在此之后你开始supervisor和supervisorctl

sudo 服务主管启动

然后

supervisorctl 重新加载

然后使用 :

将您的工作排入队列

send_mail.delay(#params_required_for_send_mail_method)

关于python - Django rq 的 Supervisord 配置不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38520957/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com