gpt4 book ai didi

php - Laravel Queue with Supervisor,运行但不处理作业

转载 作者:IT王子 更新时间:2023-10-29 00:13:28 26 4
gpt4 key购买 nike

我已经使用数据库设置了 Laravel 队列,并且配置了 Supervisor 使其保持运行,但是它会在一段时间后停止处理队列。

我正在使用 Mail::queue 发送电子邮件。如果我通过 SSH 进入服务器并运行 php/home/my/path/to/artisan --env=production --timeout=240 queue:listen --tries=5 然后它工作正常并且电子邮件发送。但显然我不想通过 SSH 来处理电子邮件,我希望队列全天候 24/7 运行,所以我安装了 supervisor 来管理它。我编辑了我的 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

当我启动该程序时,它可以正常发送我的电子邮件。但是一段时间后(通常是第二天),电子邮件将无法发送。我检查了数据库,作业表正在填满。当我通过 SSH 连接到服务器并运行 supervisorctl status 时,我得到:

laravel_queue  RUNNING    pid 21081, uptime 2 days, 23:18:51

它说 2 天,因为它一直在周末运行,今天(星期一)不工作。显然它没有运行,那么如何让 supervisord 识别它没有运行并重新启动它呢?

如果我使用 supervisorctl restart laravel_queue 手动重启它,因为它没有运行 supervisor 无法停止它并且似乎挂起直到我按下 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

再次检查状态报告队列已停止,所以我运行 supervisorctl start laravel_queue 并且我遇到了与运行重启时相同的挂起,但它已经开始处理作业和电子邮件发送。如果我再次按 CTRL + C,我会得到与上面相同的回溯。

日志

我检查了 laraqueue 的日志,把它放了一夜。今天早上我试着发了一封电子邮件,但工作表只是坐在那里等待处理。日志中全是这样的:

X-Powered-By: PHP/5.6.10^M
Content-type: text/html; charset=UTF-8^M
^M

就是这样。只是重复了很多内容。

我查看了 supervisor 日志,它只是报告了 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)



更新

将 supervisor 更新到最新版本后,我仍然遇到同样的问题。 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)

有几个主管收到退出请求并重新启动它的实例,然后日志的末尾位于它停止队列的位置之上,但由于某种原因没有再次启动它。我已经检查了 laravel 日志(在存储/日志中)但是那段时间那里什么都没有。

最佳答案

我在 Laravel 8 和 supervisor 3 上遇到了同样的问题。

我通过重新运行这些命令解决了我的问题:

sudo supervisorctl stop all

sudo supervisorctl reread

sudo supervisorctl update

sudo supervisorctl start all

希望对你有帮助

关于php - Laravel Queue with Supervisor,运行但不处理作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33217269/

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