Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

binggle's avatar

queue:work does not extend timeout with Symfony Process.

I run job with supervisor


// /etc/supervisor/laravel-worker.conf 
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /project/artisan queue:work --sleep=3 --tries=2 --timeout=3600 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=myid
numprocs=6
redirect_stderr=true
stdout_capture_maxbytes=100MB
stdout_logfile=/worker.log
stopwaitsecs=3600

I set --timeout=3600 for queue:work in worker.conf .

I have job to run.

I set setTimeout 3600 for Symfony Process.


use Symfony\Component\Process\Process;

class MyJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $timeout = 60 * 60 * 4 ;
    
    public function handle()
    {
        $cmdArr = [
            '/usr/bin/bash',
            'run-myjob.sh',
            $parameters
        ];
        $process = new Process($cmdArr);
        $process->setTimeout(60 * 60);
        $process->setIdleTimeout(60 * 10);

        $process->run(function ($type, $buffer)  {
            if (Process::ERR === $type) {
                $status = 'ERROR';
            } else {
                $status = 'OUPUT';
            }
        });

        if (
            $process->isSuccessful()
        ) {
             echo "OK";
        } else {
            throw new ProcessFailedException($process);
        }
        return  $process->getOutput();
    }
}

When I run this job with supervisor , I get this error .

   Symfony\Component\Process\Exception\ProcessTimedOutException

  The process "'/usr/bin/php8.2' 'artisan' 'queue:work' '--once' '--name=default' '--queue=default' '--backoff=0' '--memory=128' '--sleep=3' '--tries=1'" exceeded the timeout of 60 seconds.

  at vendor/symfony/process/Process.php:1152
    1148▕
    1149▕         if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
    1150▕             $this->stop(0);
    1151▕
  ➜ 1152▕             throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
    1153▕         }
    1154▕
    1155▕         if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
    1156▕             $this->stop(0);

      +18 vendor frames
  19  artisan:35

Why it says the timeout is 60 seconds only?

I set 3600 seconds for queue:work and Symfony\Component\Process\Process .

Actually I am not sure if this is cause of Symfony Process.

How can I fix this ?

0 likes
7 replies
binggle's avatar

@Sinnbeck

I did this


php artisan quque:clear 
php artisan quque:flush

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*

and tried after rebooting server.

pcntl is elabled on my server.

$ php -i | grep pcntl
pcntl support => enabled
Sinnbeck's avatar

@binggle What about if you move the logic to a command so you can run it directly and try that. Does that timeout in the same way?

binggle's avatar

@Sinnbeck

Actually that logics inside job was moved from Commands.

When I call Job and the job call Commands , the Commands have not fired.

I think combination with Cronjob and Command would be the best for stability, instead of Queued Job.

Because the Cronjob is really dependent on OS system.

But my client want faster processing.

binggle's avatar

I set --try=2 , but the error says --tries=1 .

Wired.

Please or to participate in this conversation.