I have set up Laravel Queue using the database and I've configured Supervisor to keep it running, however it stops processing the queue after a while.
我已经使用数据库设置了Laravel Queue,并且我已经配置了Supervisor以使其保持运行,但是它会在一段时间后停止处理队列。
I'm using Mail::queue
to send e-mails. If I SSH into the server and run php /home/my/path/to/artisan --env=production --timeout=240 queue:listen --tries=5
then it works fine and the e-mails send. But obviously I don't want to have to SSH in to process the e-mails, I want the queue running 24/7 so I installed supervisor to manage this. I have edited my supervisord.conf file to include the following program:
我正在使用Mail :: queue发送电子邮件。如果我SSH到服务器并运行php / home / my / path / to / artisan --env = production --timeout = 240 queue:listen --tries = 5那么它工作正常并且电子邮件发送。但显然我不想使用SSH来处理电子邮件,我希望队列全天候运行,所以我安装了主管来管理这个。我编辑了我的supervisord.conf文件以包含以下程序:
[program:laravel_queue]
command=php /home/my/path/to/artisan --env=production --timeout=240 queue:listen --tries=5
autostart=true
autorestart=true
logfile=/var/log/laraqueue.log
And when I start the program it works, my e-mails send. However after some time (normally the next day) the e-mails wont send. I check the database and the jobs table is filling up. When I SSH into the server and run supervisorctl status
I get:
当我启动它的程序时,我的电子邮件发送。但是经过一段时间(通常是第二天),电子邮件就不会发送了。我检查数据库,并填写了作业表。当我SSH到服务器并运行supervisorctl状态时,我得到:
laravel_queue RUNNING pid 21081, uptime 2 days, 23:18:51
It's saying 2 days as it's been running over the weekend and not working today (Monday). Clearly it's not running, so how do I get supervisord to recognise that it's not running and restart it?
这是2天,因为它已经在周末运行而今天(星期一)没有工作。显然它没有运行,所以如何让supervisord认识到它没有运行并重新启动呢?
If I manually restart it with supervisorctl restart laravel_queue
, because it's not running supervisor can't stop it and just seems to hang until I press CTRL + C. At which point I get a traceback that I don't understand:
如果我使用supervisorctl restart laravel_queue手动重启它,因为它没有运行主管无法阻止它并且似乎挂起直到我按CTRL + C.此时我得到一个我不理解的追溯:
Traceback (most recent call last):
File "/usr/bin/supervisorctl", line 6, in <module>
main()
File "/usr/lib/python2.6/site-packages/supervisor/supervisorctl.py", line 598, in main
c.onecmd(" ".join(options.args))
File "/usr/lib/python2.6/site-packages/supervisor/supervisorctl.py", line 86, in onecmd
return func(arg)
File "/usr/lib/python2.6/site-packages/supervisor/supervisorctl.py", line 467, in do_restart
self.do_stop(arg)
File "/usr/lib/python2.6/site-packages/supervisor/supervisorctl.py", line 433, in do_stop
result = supervisor.stopProcess(processname)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "/usr/lib/python2.6/site-packages/supervisor/options.py", line 1309, in request
errcode, errmsg, headers = h.getreply()
File "/usr/lib64/python2.6/httplib.py", line 1064, in getreply
response = self._conn.getresponse()
File "/usr/lib64/python2.6/httplib.py", line 990, in getresponse
response.begin()
File "/usr/lib64/python2.6/httplib.py", line 391, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python2.6/httplib.py", line 349, in _read_status
line = self.fp.readline()
File "/usr/lib64/python2.6/socket.py", line 433, in readline
data = recv(1)
KeyboardInterrupt
Checking the status again reports the queue as stopped, so I run supervisorctl start laravel_queue
and I get the same hang as when running restart, but it has started as the jobs are processed and e-mails sent. If I press CTRL + C again I get the same traceback as above.
再次检查状态会将队列报告为已停止,因此我运行supervisorctl start laravel_queue并获得与运行重启时相同的挂起,但它已在处理作业和发送电子邮件时启动。如果我再次按CTRL + C,我会得到与上面相同的追溯。
Log
I've checked the laraqueue log after leaving it over night. I tried to send an e-mail this morning and the job table is just sitting there waiting to process. The log is just full of this:
我把它留了一夜之后检查了laraqueue日志。我今天早上试着发电子邮件,工作台正坐在那里等待处理。日志就是这样的:
X-Powered-By: PHP/5.6.10^M
Content-type: text/html; charset=UTF-8^M
^M
That's it. Just lots of that being repeated.
而已。只是很多重复。
I've checked the supervisor log and it just reports the successful start of laravel_queue. For completion the log is:
我检查了主管日志,它只是报告了laravel_queue的成功启动。完成后,日志是:
2015-10-21 14:25:24,997 INFO /var/tmp/supervisor.sock:Medusa (V1.1.1.1) started at Wed Oct 21 14:25:24 2015
Hostname: <unix domain socket>
Port:/var/tmp/supervisor.sock
2015-10-21 14:25:25,099 CRIT Running without any HTTP authentication checking
2015-10-21 14:25:25,107 INFO daemonizing the process
2015-10-21 14:25:25,108 INFO supervisord started with pid 3407
2015-10-21 14:25:25,115 INFO spawned: 'laravel_queue' with pid 3409
2015-10-21 14:25:26,729 INFO success: laravel_queue entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
UPDATE
After updating supervisor to the latest version, I'm still having the same issue. The laraqueue.log has the same content as before, nothing useful. However the supervisor log has a little more in it this time:
在将主管更新到最新版本后,我仍然遇到同样的问题。 laraqueue.log具有与以前相同的内容,没有任何用处。但是这次主管日志还有更多内容:
2015-10-22 10:19:59,454 CRIT received SIGTERM indicating exit request
2015-10-22 10:19:59,454 INFO waiting for laravel_queue to die
2015-10-22 10:19:59,460 INFO stopped: laravel_queue (terminated by SIGTERM)
2015-10-22 10:19:59,460 INFO received SIGCLD indicating a child quit
2015-10-22 10:26:02,019 CRIT Supervisor running as root (no user in config file)
2015-10-22 10:26:02,085 CRIT Server 'inet_http_server' running without any HTTP authentication checking
2015-10-22 10:26:02,092 INFO daemonizing the supervisord process
2015-10-22 10:26:02,093 INFO supervisord started with pid 17268
2015-10-22 10:26:03,105 INFO spawned: 'laravel_queue' with pid 17269
2015-10-22 10:26:04,107 INFO success: laravel_queue entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2015-10-22 10:37:22,157 WARN received SIGTERM indicating exit request
2015-10-22 10:37:22,157 INFO waiting for laravel_queue to die
2015-10-22 10:37:22,163 INFO stopped: laravel_queue (terminated by SIGTERM)
There was a couple instances of supervisor receiving the exit request and starting it back up, and then the end of the log is above where it stops the queue, but doesn't start it again for some reason. I've checked the laravel log (in storage/logs) but there's nothing in there for around that time.
有几个主管接收退出请求并重新启动它的实例,然后日志的结尾位于停止队列的位置,但由于某种原因不再启动它。我已经检查了laravel日志(在存储/日志中)但是那个时间周围什么也没有。
1 个解决方案
#1
3
Check what version of Supervisor you have. Some package managers have been known to forget to update Supervisor. I think your problem will be fixed by updating Supervisor. For example v2.1 of Supervisor is from 2007 and is still in some packages.
检查您拥有的Supervisor版本。已知一些包管理员忘记更新Supervisor。我认为你的问题将通过更新主管来解决。例如,Supervisor的v2.1是从2007年开始的,并且仍在某些软件包中。
Current version of Supervisor is v3.13 though some say (see reference at bottom) v3 is the last stable version.
当前版本的Supervisor是v3.13虽然有人说(参见底部参考)v3是最后一个稳定版本。
Check what version of Supervisor you are using
检查您正在使用的Supervisor版本
[root@test supervisor]# yum list | grep supervisor
Compare version shown to: https://pypi.python.org/pypi/supervisor
比较显示的版本:https://pypi.python.org/pypi/supervisor
Remove and Install (easy install is nice)
删除并安装(易于安装很好)
[root@test ~]$ yum remove supervisor
[root@test ~]$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python
[root@test ~]$ sudo easy_install supervisor
Searching for supervisor
Reading https://pypi.python.org/simple/supervisor/
Best match: supervisor 3.0
Update:
Please take a moment to look here, it's well worth it ( http://ahmed.amayem.com/running-a-node-js-app-ghost-in-the-background-continuously-with-supervisor-supervisord/ ). Though he is running node.js/ghost with Supervisor, I don't think that matters since this is all about Supervisor!
请花点时间看看这里,非常值得(http://ahmed.amayem.com/running-a-node-js-app-ghost-in-the-background-continuously-with-supervisor-supervisord/) 。虽然他和Supervisor一起运行node.js / ghost,但我认为这并不重要,因为这完全是关于Supervisor的!
Refs: https://github.com/Supervisor/supervisor/issues/165
http://ahmed.amayem.com/woes-of-using-an-outdated-supervisord-to-run-a-node-js-app-ghost/
#1
3
Check what version of Supervisor you have. Some package managers have been known to forget to update Supervisor. I think your problem will be fixed by updating Supervisor. For example v2.1 of Supervisor is from 2007 and is still in some packages.
检查您拥有的Supervisor版本。已知一些包管理员忘记更新Supervisor。我认为你的问题将通过更新主管来解决。例如,Supervisor的v2.1是从2007年开始的,并且仍在某些软件包中。
Current version of Supervisor is v3.13 though some say (see reference at bottom) v3 is the last stable version.
当前版本的Supervisor是v3.13虽然有人说(参见底部参考)v3是最后一个稳定版本。
Check what version of Supervisor you are using
检查您正在使用的Supervisor版本
[root@test supervisor]# yum list | grep supervisor
Compare version shown to: https://pypi.python.org/pypi/supervisor
比较显示的版本:https://pypi.python.org/pypi/supervisor
Remove and Install (easy install is nice)
删除并安装(易于安装很好)
[root@test ~]$ yum remove supervisor
[root@test ~]$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python
[root@test ~]$ sudo easy_install supervisor
Searching for supervisor
Reading https://pypi.python.org/simple/supervisor/
Best match: supervisor 3.0
Update:
Please take a moment to look here, it's well worth it ( http://ahmed.amayem.com/running-a-node-js-app-ghost-in-the-background-continuously-with-supervisor-supervisord/ ). Though he is running node.js/ghost with Supervisor, I don't think that matters since this is all about Supervisor!
请花点时间看看这里,非常值得(http://ahmed.amayem.com/running-a-node-js-app-ghost-in-the-background-continuously-with-supervisor-supervisord/) 。虽然他和Supervisor一起运行node.js / ghost,但我认为这并不重要,因为这完全是关于Supervisor的!
Refs: https://github.com/Supervisor/supervisor/issues/165
http://ahmed.amayem.com/woes-of-using-an-outdated-supervisord-to-run-a-node-js-app-ghost/