首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Django rq不工作的监督配置

Django rq不工作的监督配置
EN

Stack Overflow用户
提问于 2016-07-22 07:45:49
回答 2查看 2.2K关注 0票数 4

我下面是:把RQ置于监督之下

我的工作:

代码语言:javascript
复制
@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

我能够使用rq队列执行任务。但不是用监控配置。监督配置:

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

代码语言:javascript
复制
[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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-07-29 11:36:49

回答我自己的问题。

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

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

开发服务器的配置:

代码语言:javascript
复制
[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

关于当地环境:

代码语言:javascript
复制
[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

在此之后,你开始担任主管和监督。

sudo service supervisor start

然后

supervisorctl reload

然后使用以下方法对作业进行排队:

send_mail.delay(#params_required_for_send_mail_method)

票数 3
EN

Stack Overflow用户

发布于 2017-11-23 00:36:19

我就这样解决了。

首先,我的supervisord.conf (把它放在/etc/主管/)。与默认情况相比,主要的更改是将日志文件放在我可以管理它们的位置(即我的其他日志文件所在的位置)。

代码语言:javascript
复制
; supervisor config file
[unix_http_server]
file=/tmp/supervisor.sock   ; the path to the socket file

[supervisord]
logfile=/home/ubuntu/backend/logs/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/home/ubuntu/backend/logs/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/home/ubuntu/backend/logs/supervisor            ; ('AUTO' child log dir, default $TEMP)


; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf

运行rqworks的配置如下所示:(放置在文件/etc/ looks / config /rqworker.conf中)。对于此文件,请注意目录。我还将用户更改为运行我的网站的同一个用户:

代码语言:javascript
复制
[program:rqworker]
command= /home/ubuntu/backend/opt/api/deploy_env/bin/python manage.py rqworker
process_name=%(program_name)%(process_num)s

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

; 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/ubuntu/backend/opt/api/django_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

autostart=true
autorestart=true
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38520957

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档