@@ -76,6 +76,11 @@ class Processor {
7676 */
7777 protected QueueProcessesTable $ QueueProcesses ;
7878
79+ /**
80+ * @var \Queue\Model\Entity\QueuedJob|null
81+ */
82+ protected ?QueuedJob $ currentJob = null ;
83+
7984 /**
8085 * @param \Queue\Console\Io $io
8186 * @param \Psr\Log\LoggerInterface $logger
@@ -199,6 +204,7 @@ public function run(array $args): int {
199204 * @return void
200205 */
201206 protected function runJob (QueuedJob $ queuedJob , string $ pid ): void {
207+ $ this ->currentJob = $ queuedJob ;
202208 $ this ->io ->out ('Running Job of type " ' . $ queuedJob ->job_task . '" ' );
203209 $ this ->log ('job ' . $ queuedJob ->job_task . ', id ' . $ queuedJob ->id , $ pid , false );
204210 $ taskName = $ queuedJob ->job_task ;
@@ -246,6 +252,7 @@ protected function runJob(QueuedJob $queuedJob, string $pid): void {
246252
247253 $ this ->QueuedJobs ->markJobDone ($ queuedJob );
248254 $ this ->io ->out ('Job Finished. ' );
255+ $ this ->currentJob = null ;
249256 }
250257
251258 /**
@@ -318,6 +325,12 @@ protected function getTaskConf(): array {
318325 * @return void
319326 */
320327 protected function exit (int $ signal ): void {
328+ if ($ this ->currentJob ) {
329+ $ failureMessage = 'Worker process terminated by signal (SIGTERM) - job execution interrupted due to timeout or manual termination ' ;
330+ $ this ->QueuedJobs ->markJobFailed ($ this ->currentJob , $ failureMessage );
331+ $ this ->logError ('Job ' . $ this ->currentJob ->job_task . ' (id ' . $ this ->currentJob ->id . ') failed due to worker termination ' , $ this ->pid );
332+ $ this ->io ->out ('Current job marked as failed due to worker termination. ' );
333+ }
321334 $ this ->exit = true ;
322335 }
323336
0 commit comments