TL;DR
heroku ps:scale worker=1
Procfile
web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
worker: php artisan queue:restart && php artisan queue:work database --tries=3
実装
laravel側
routes/api.php
Route::post('queue-data',function(){
$accessAt=now();
$data=Str::random(10);
\App\Jobs\StoreQueueData::dispatch($accessAt,$data)->delay(now()->addSeconds(3));
return response()->json(['data' => $data,'access_at'=>$accessAt]);
});
app/Jobs/StoreQueueData.php
public function handle()
{
$queue=QueueData::create([
'data'=>$this->data,
'access_at'=>$this->accessAt,
'handle_at'=>now(),
]);
Log::info('handle',['queue'=>$queue]);
}
heroku設定
heroku ps:scale worker=1
Procfile
web: vendor/bin/heroku-php-nginx -C nginx_app.conf public/
worker: php artisan queue:restart && php artisan queue:work database --tries=3