Skip to content

Commit

Permalink
Merge pull request #17 from aledeg/server-kill
Browse files Browse the repository at this point in the history
Change how the program listening are killed
  • Loading branch information
ddelnano committed Apr 27, 2016
2 parents 93733ef + a100e0b commit 5431561
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,19 @@ public function processMessage($message, $client)

private function killProgramsOnDreddPort()
{
// get any programs running on the dredd port
$string = shell_exec("lsof -i tcp:61321");
foreach ([SIGTERM, SIGINT, SIGHUP, SIGKILL] as $signal) {
// get any programs running on the dredd port
if ($string = shell_exec("lsof -i tcp:61321")) {
$regex = '/(?:php\s*)(\d*)/';

$regex = '/(?:php\s*)(\d*)/';
// get matches if any programs are returned
preg_match($regex, $string, $matches);

// get matches if any programs are returned
preg_match($regex, $string, $matches);
// execute kill command so server can listen on port
shell_exec("kill -$signal {$matches[1]}");

// execute kill command so server can listen on port
shell_exec("kill -9 {$matches[1]}");
sleep(3);
}
}
}
}

0 comments on commit 5431561

Please sign in to comment.