我已经实现了与laravel 5.4,带有redis和队列的laravel-echo的实时聊天。我在队列中遇到问题,以下是一些代码片段
主管设置为
[program:qwikkar-staging-queue-worker]
process_name=%(program_name)s_%(process_num)02d
command=sudo php /var/www/html/Qwikkar_staging/artisan queue:work --sleep=10 --tries=3 --daemon
autostart=true
autorestart=true
user=ubuntu
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/html/Qwikkar_staging/storage/logs/queue-worker.log
.env设置如下
BROADCAST_DRIVER=redis
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
错误记录在
laravel.logs
文件中Illuminate\Queue\MaxAttemptsExceededException: A queued job has been attempted too many times. The job may have previously timed out.
in /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:383
Stack trace:
#0 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(311): Illuminate\Queue\Worker->markJobAsFailedIfAlreadyExceedsMaxAttempts('redis', Object(Illuminate\Queue\Jobs\RedisJob), 3)
#1 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(267): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#2 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(113): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#3 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Worker->daemon('redis', 'default', Object(Illuminate\Queue\WorkerOptions))
#4 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default')
#5 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#6 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#7 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#9 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#10 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
#11 /var/www/html/Qwikkar_staging/vendor/symfony/console/Command/Command.php(264): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#12 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#13 /var/www/html/Qwikkar_staging/vendor/symfony/console/Application.php(874): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/Qwikkar_staging/vendor/symfony/console/Application.php(228): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/Qwikkar_staging/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/Qwikkar_staging/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/html/Qwikkar_staging/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 {main}
重置就是一切都很好,消息已发布,保存在数据库中并完美列在套接字上。在主管状态“supervisorctl”之后显示
qwikkar-stagin-echo-server-worker:qwikkar-stagin-echo-server-worker_00 RUNNING pid 9187, uptime 2 days, 19:07:12
qwikkar-staging-queue-worker:qwikkar-staging-queue-worker_00 RUNNING pid 9190, uptime 2 days, 19:07:12
最佳答案
只需删除--sleep=10 --tries=3 --daemon
,然后使用此命令更新您的主管sudo supervisor update
并尝试启动您的程序sudo supervisorctl
supervisor> start qwikkar-stagin-echo-server-worker:qwikkar-stagin-echo-server-worker_00
希望我能帮到你..