function stopAndWait()
{
$running = $this->isRunning();
if ($running) {
// Stop the server.
$success = $this->stop();
if (!$success) {
return false;
}
// Give the server time to actually go down.
// But not more than 10 second.
$logFile = $this->_getLogFileName();
file_put_contents($logFile, 'Waiting for server to stop ', FILE_APPEND);
$maxWait = 10;
while ($this->isRunning() && $maxWait > 0) {
file_put_contents($logFile, '.', FILE_APPEND);
sleep(1);
$maxWait--;
}
if ($maxWait == 0) {
file_put_contents($logFile, ' timeout' . PHP_EOL, FILE_APPEND);
return false;
} else {
file_put_contents($logFile, PHP_EOL, FILE_APPEND);
}
}
return true;
}