如何正确地从断开的beanstalk退出工匠工人?

时间:2015-10-06 14:14:29

标签: laravel laravel-5 laravel-5.1 beanstalkd

我正在使用laravel 5.1,其中beanstalkd与主管保持一致。

问题是: 1)工匠队列:work beanstalkd --sleep = 3 --tries = 3 --damon 2)sudo service beanstalkd stop

多数民众赞成。我24小时内在laravel.log中收到400G的错误:

[2015-10-06 17:09:18] local.ERROR: exception 'Pheanstalk\Exception\ConnectionException' with message 'Socket error 111: Connection refused (connecting to localhost:11300)' in /home/glue/proj/crowdbanner/vendor/pda/pheanstalk/src/Socket/NativeSocket.php:45

如何正确地避免这种情况并在beanstalk死亡时停止工作?

1 个答案:

答案 0 :(得分:0)

你会尝试/捕捉任何其他例外 - 并且做任何你需要的事情,从睡觉和稍后再次尝试,到完全退出。

try {
    // reserve a job
    // act on the job
    // delete the job if it's complete.
} catch (Pheanstalk\Exception\ConnectionException $e) {
    echo "can't connect to Beanstalkd";
    exit 99;
}