Skip to content

Commit

Permalink
[10.x] Add POSIX compliant cleanup to artisan serve (#49943)
Browse files Browse the repository at this point in the history
* Add POSIX compliant cleanup to php artisan serve

Fixes #49941

* Style CI

* Move cleanup to a better location

* Use built in server abstraction

* Update ServeCommand.php

---------

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
Tofandel and taylorotwell authored Feb 2, 2024
1 parent 3734ae9 commit c4f46ab
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Illuminate/Foundation/Console/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ protected function startProcess($hasEnvironment)
return in_array($key, static::$passthroughVariables) ? [$key => $value] : [$key => false];
})->all());

$this->trap([SIGTERM, SIGINT, SIGHUP, SIGUSR1, SIGUSR2, SIGQUIT], function ($signal) use ($process) {
if ($process->isRunning()) {
$process->stop(10, $signal);
}

exit;
});

$process->start($this->handleProcessOutput());

return $process;
Expand Down

0 comments on commit c4f46ab

Please sign in to comment.