Improve CLI web serving autodetection
This commit is contained in:
parent
947ad34153
commit
fba63602c9
|
@ -9,6 +9,15 @@ class WebCommand extends Command
|
|||
{
|
||||
public function serveAction()
|
||||
{
|
||||
$minVersion = '5.4.0';
|
||||
if (version_compare(PHP_VERSION, $minVersion) < 0) {
|
||||
throw new Exception(sprintf(
|
||||
'You are running PHP %s, internal webserver requires %s.',
|
||||
PHP_VERSION,
|
||||
$minVersion
|
||||
));
|
||||
}
|
||||
|
||||
$fork = $this->params->get('daemonize');
|
||||
$basedir = $this->params->shift();
|
||||
$socket = $this->params->shift();
|
||||
|
@ -19,19 +28,25 @@ class WebCommand extends Command
|
|||
// throw new Exception('Socket is required');
|
||||
}
|
||||
if ($basedir === null) {
|
||||
throw new Exception('Basedir is required');
|
||||
$basedir = dirname(ICINGA_APPDIR) . '/public';
|
||||
if (! file_exists($basedir) || ! is_dir($basedir)) {
|
||||
throw new Exception('Basedir is required');
|
||||
}
|
||||
}
|
||||
$basedir = realpath($basedir);
|
||||
|
||||
if ($fork) {
|
||||
$this->forkAndExit();
|
||||
}
|
||||
echo "Serving Icingaweb from $basedir\n";
|
||||
$cmd = sprintf(
|
||||
'%s -S %s -t %s %s',
|
||||
readlink('/proc/self/exe'),
|
||||
$socket,
|
||||
$basedir,
|
||||
ICINGA_LIBDIR . '/Icinga/Application/webrouter.php'
|
||||
$basedir . '/index.php'
|
||||
);
|
||||
|
||||
// TODO: Store webserver log, switch uid, log index.php includes, pid file
|
||||
if ($fork) {
|
||||
exec($cmd);
|
||||
|
|
Loading…
Reference in New Issue