summaryrefslogtreecommitdiff
path: root/src/jobs
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-04-13 02:17:19 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-04-13 02:17:19 +0300
commit7330a35806ffc1c91f0765d1fe19df2c459d5579 (patch)
tree489bad797be3bfadcb966bbfb290dd5044f74189 /src/jobs
parent544f2444211aa1ad9e3611818fb87e8a8882ff55 (diff)
add signals example
Diffstat (limited to 'src/jobs')
-rw-r--r--src/jobs/LongRunningTask.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/jobs/LongRunningTask.php b/src/jobs/LongRunningTask.php
new file mode 100644
index 0000000..3684055
--- /dev/null
+++ b/src/jobs/LongRunningTask.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace jobs;
+
+use jobd\exceptions\JobInterruptedException;
+
+class LongRunningTask extends \Job
+{
+
+ public function run()
+ {
+ set_time_limit(0);
+ sleep(120);
+ echo 'ok';
+ }
+
+ public function signalHandler(int $signal)
+ {
+ if ($signal == 15) {
+ throw new JobInterruptedException(0, 'i\'m exiting gracefully');
+ }
+ }
+
+}