Skip to content

Commit c622362

Browse files
committed
Implement Unix task time limit
1 parent 269b6fc commit c622362

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ via Composer:
3030
composer require vectorial1024/laravel-process-async
3131
```
3232

33+
Additionally:
34+
35+
- For Unix systems (e.g. MacOS, Ubuntu, ...), the following are also required:
36+
- GNU Core Utilities (`coreutils`, most probably preinstalled already)
37+
3338
This library supports Unix and Windows; see the Testing section for more details.
3439

3540
## Change log

src/AsyncTask.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ public function start(): void
9494
}
9595
// assume anything not windows to be unix
9696
// unix use nohup
97-
$this->runnerProcess = Process::quietly()->start("nohup $baseCommand");
97+
// check time limit settings
98+
$timeoutClause = "";
99+
if ($this->timeLimit > 0) {
100+
$timeoutClause = "timeout {$this->timeLimit}";
101+
}
102+
$this->runnerProcess = Process::quietly()->start("nohup $timeoutClause $baseCommand");
98103
}
99104

100105
/**

0 commit comments

Comments
 (0)