Skip to content

Commit

Permalink
Fix: Resolved errors and added support for windows platform
Browse files Browse the repository at this point in the history
  • Loading branch information
yourchocomate committed Mar 13, 2024
1 parent bcbc8bb commit 70f7aa1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Servers/Reverb/Console/Commands/StartServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,35 @@ protected function ensurePulseEventsAreCollected(LoopInterface $loop, int $inter
*/
public function getSubscribedSignals(): array
{
return [SIGINT, SIGTERM];
if (! windows_os()) {
return [SIGINT, SIGTERM, SIGTSTP];
}

$this->handleSignalWindows();

return [];
}

/**
* Handle the signals sent to the server.
*/
public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false
public function handleSignal(int $signal = 0, int|false $previousExitCode = 0): int|false
{
$this->components->info('Gracefully terminating connections.');

$this->gracefullyDisconnect();

return $previousExitCode;
}

/**
* Handle the signals sent to the server on Windows.
*/

public function handleSignalWindows(): void
{
if(function_exists('sapi_windows_set_ctrl_handler')) {
sapi_windows_set_ctrl_handler(fn () => exit($this->handleSignal()));
}
}
}

0 comments on commit 70f7aa1

Please sign in to comment.