Sty*_*hon 18 php supervisord laravel
我已经使用数据库设置了Laravel Queue,并且我已经配置了Supervisor以使其保持运行,但是它会在一段时间后停止处理队列.
我正在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
Run Code Online (Sandbox Code Playgroud)
当我启动它的程序时,我的电子邮件发送.但是经过一段时间(通常是第二天),电子邮件就不会发送了.我检查数据库,并且工作表填满了.当我SSH到服务器并运行时,supervisorctl status我得到:
laravel_queue RUNNING pid 21081, uptime 2 days, 23:18:51
Run Code Online (Sandbox Code Playgroud)
这是说2天,因为它已经在周末运行而今天(星期一)没有工作.显然它没有运行,所以如何让supervisord认识到它没有运行并重新启动呢?
如果我手动重新启动它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
Run Code Online (Sandbox Code Playgroud)
再次检查状态supervisorctl start laravel_queue会将队列报告为已停止,因此我运行并获得与运行重新启动时相同的挂起,但它已在处理作业和发送电子邮件时启动.如果我再次按CTRL + C,我会得到与上面相同的追溯.
我把它留了一夜后检查了laraqueue日志.我今天早上试着发电子邮件,工作台正坐在那里等待处理.日志刚满了这个:
X-Powered-By: PHP/5.6.10^M
Content-type: text/html; charset=UTF-8^M
^M
Run Code Online (Sandbox Code Playgroud)
而已.只是很多重复.
我检查了主管日志,它只是报告了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)
Run Code Online (Sandbox Code Playgroud)
在将主管更新到最新版本后,我仍然遇到同样的问题.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)
Run Code Online (Sandbox Code Playgroud)
有几个主管接收退出请求并重新启动它的实例,然后日志的结尾位于停止队列的位置,但由于某种原因不再启动它.我已经检查了laravel日志(在存储/日志中)但是那个时间周围什么都没有.
我对 Laravel 8 和主管 3 有同样的问题。
我通过重新运行这些命令解决了我的问题:
sudo supervisorctl stop all
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start all
Run Code Online (Sandbox Code Playgroud)
我希望它有帮助。
检查您拥有的 Supervisor 版本。众所周知,一些包管理器会忘记更新 Supervisor。我认为您的问题将通过更新主管来解决。例如,Supervisor 的 v2.1 是 2007 年的,并且仍在某些软件包中。
Supervisor 的当前版本是 v3.13,尽管有人说(见底部参考)v3 是最后一个稳定版本。
检查您使用的是哪个版本的 Supervisor
[root@test supervisor]# yum list | grep supervisor
Run Code Online (Sandbox Code Playgroud)
比较显示的版本:https : //pypi.python.org/pypi/supervisor
删除和安装(简单安装很好)
[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
Run Code Online (Sandbox Code Playgroud)
更新:
请花点时间看看这里,它非常值得(http://ahmed.amayem.com/running-a-node-js-app-ghost-in-the-background-continuously-with-supervisor-supervisord/) . 尽管他与 Supervisor 一起运行 node.js/ghost,但我认为这并不重要,因为这完全是关于 Supervisor 的!
参考:https : //github.com/Supervisor/supervisor/issues/165
http://ahmed.amayem.com/woes-of-using-an-outdated-supervisord-to-run-a-node-js-app-ghost/
| 归档时间: |
|
| 查看次数: |
10847 次 |
| 最近记录: |