首先,作业文件内的超时不会杀死工作程序。 在工作中使用睡眠功能会使工作人员冻结,而没有任何反应。
日志: [2019-04-03 19:53:25] local.INFO:入睡前
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class FetchAmazonOrders implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $timeout = 1;
public function __construct()
{
}
public function handle()
{
myLog("before sleep");
sleep(2);
myLog("after sleep");
}
public function failed($exception = null)
{
myLog("failed");
}
}
['local' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default', 'high', 'medium', 'low'],
'balance' => 'auto',
'processes' => 10,
'tries' => 1,
'timeout' => 1,
'retry_after' => 1
],
],]