Skip to content

Commit 3db8772

Browse files
committed
Merge remote-tracking branch 'github/2.0'
2 parents 10d39d2 + 5be4f1f commit 3db8772

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

helpers.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,15 @@ function process_is_running($keyword)
152152
return empty($output) ? false : true;
153153
}
154154

155+
/**
156+
* @param $port
157+
* @return bool
158+
*/
159+
function port_is_running($port)
160+
{
161+
$command = "lsof -i:{$port}";
162+
163+
exec($command, $output);
164+
165+
return empty($output) ? false : true;
166+
}

src/Server.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,15 @@ public function watch(array $directories = ['.'])
544544
*/
545545
public function isRunning()
546546
{
547-
if (file_exists($this->pidFile)) {
548-
return process_kill((int) file_get_contents($this->pidFile), 0);
547+
if (file_exists($this->config['pid_file'])) {
548+
return posix_kill(file_get_contents($this->config['pid_file']), 0);
549+
}
550+
551+
if ($is_running = process_is_running("{$this->name} master")) {
552+
$is_running = port_is_running($this->port);
549553
}
550554

551-
return process_is_running("{$this->name} master");
555+
return $is_running;
552556
}
553557

554558
/**

0 commit comments

Comments
 (0)