Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how the program listening are killed #17

Merged
merged 1 commit into from
Apr 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}
}
}
}