Skip to content

Commit b983c6e

Browse files
RobertBoesreinink
andauthored
Conditionally use pcntl extension in inertia:start-ssr command (#492)
* Add pcntl to requirements * Move ext-pcntl to suggest and add check to StartSsr command * Tweak `ext-pcntl` suggestion message * Update `inertia:start-ssr` command to only use `pcntl` when it's available Co-authored-by: Jonathan Reinink <[email protected]>
1 parent 5106f9d commit b983c6e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"mockery/mockery": "^1.3.3",
3636
"phpunit/phpunit": "^8.0|^9.5.8"
3737
},
38+
"suggest": {
39+
"ext-pcntl": "Recommended when running the Inertia SSR server via the `inertia:start-ssr` artisan command."
40+
},
3841
"extra": {
3942
"laravel": {
4043
"providers": [

src/Commands/StartSsr.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ public function handle(): int
5656
$process->setTimeout(null);
5757
$process->start();
5858

59-
$stop = function () use ($process) {
60-
$process->stop();
61-
};
62-
pcntl_async_signals(true);
63-
pcntl_signal(SIGINT, $stop);
64-
pcntl_signal(SIGQUIT, $stop);
65-
pcntl_signal(SIGTERM, $stop);
59+
if (extension_loaded('pcntl')) {
60+
$stop = function () use ($process) {
61+
$process->stop();
62+
};
63+
pcntl_async_signals(true);
64+
pcntl_signal(SIGINT, $stop);
65+
pcntl_signal(SIGQUIT, $stop);
66+
pcntl_signal(SIGTERM, $stop);
67+
}
6668

6769
foreach ($process as $type => $data) {
6870
if ($process::OUT === $type) {

0 commit comments

Comments
 (0)