【发布时间】:2018-03-21 13:33:00
【问题描述】:
我有一个使用 mod_wsgi 守护进程的测试 Django 站点,并设置了一个简单的 Celery 任务以通过电子邮件发送联系表,并安装了主管。
我知道 Django 代码是正确的。
我遇到的问题是,当我提交表单时,我只收到一条消息 - 第一条消息。随后填写的联系表格根本不会发送任何消息。
在我的服务器上,我有另一个测试站点,其中运行一个配置的主管任务,它使用 Django 服务器(即它不使用 mod_wsgi)。如果我这样做,我的两个任务都运行良好
sudo supervisorctl status
这是我上面描述的任务的 conf 文件,保存在
/etc/supervisor/conf.d
此实例中的用户称为 myuser
[program:test_project]
command=/home/myuser/virtualenvs/test_project_env/bin/celery -A test_project worker --loglevel=INFO --concurrency=10 -n worker2@%%h
directory=/home/myuser/djangoprojects/test_project
user=myuser
numprocs=1
stdout_logfile=/var/log/celery/test_project.out.log
stderr_logfile=/var/log/celery/test_project.err.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
stopasgroup=true
; Set Celery priority higher than default (999)
; so, if rabbitmq is supervised, it will start first.
priority=1000
我的其他测试站点将此设置为命令 - note worker1@%%h
command=/home/myuser/virtualenvs/another_test_project_env/bin/celery -A another_test_project worker --loglevel=INFO --concurrency=10 -n worker1@%%h
我显然做错了,因为我的表单只提交了。如果我查看上面提到的 out.log 文件,我只看到第一个任务,其他表单提交看不到任何内容。
非常感谢。
更新
我在上午 8.32(格林威治标准时间)提交了收到的第一份表格,然后如上所述,不久之后又提交了一份未创建任务的表格。刚做完问题,我在 9.15 再次提交了表单,为此创建了一个任务并收到了消息!然后我再次提交了表单,但没有再次创建任务。希望这会有所帮助!
【问题讨论】:
标签: django celery supervisord