From 7330a35806ffc1c91f0765d1fe19df2c459d5579 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Thu, 13 Apr 2023 02:17:19 +0300 Subject: add signals example --- src/launcher.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/launcher.php') diff --git a/src/launcher.php b/src/launcher.php index d1b9892..8cd9fda 100644 --- a/src/launcher.php +++ b/src/launcher.php @@ -7,6 +7,8 @@ $job = null; register_shutdown_function(function() { global $job; + if ($job instanceof \jobd\exceptions\JobInterruptedException) + exit($job->getCode()); if ($job !== true) exit(1); }); @@ -25,6 +27,9 @@ if ($job->status != Job::STATUS_RUNNING) try { if ($job->run() !== false) $job = true; +} catch (\jobd\exceptions\JobInterruptedException $e) { + fprintf(STDERR, $e->getMessage()."\n"); + $job = $e; } catch (Exception $e) { fprintf(STDERR, $e.''); exit(1); -- cgit v1.2.3