mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
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()
|
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');
|
$fork = $this->params->get('daemonize');
|
||||||
$basedir = $this->params->shift();
|
$basedir = $this->params->shift();
|
||||||
$socket = $this->params->shift();
|
$socket = $this->params->shift();
|
||||||
@ -19,19 +28,25 @@ class WebCommand extends Command
|
|||||||
// throw new Exception('Socket is required');
|
// throw new Exception('Socket is required');
|
||||||
}
|
}
|
||||||
if ($basedir === null) {
|
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) {
|
if ($fork) {
|
||||||
$this->forkAndExit();
|
$this->forkAndExit();
|
||||||
}
|
}
|
||||||
|
echo "Serving Icingaweb from $basedir\n";
|
||||||
$cmd = sprintf(
|
$cmd = sprintf(
|
||||||
'%s -S %s -t %s %s',
|
'%s -S %s -t %s %s',
|
||||||
readlink('/proc/self/exe'),
|
readlink('/proc/self/exe'),
|
||||||
$socket,
|
$socket,
|
||||||
$basedir,
|
$basedir,
|
||||||
ICINGA_LIBDIR . '/Icinga/Application/webrouter.php'
|
$basedir . '/index.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: Store webserver log, switch uid, log index.php includes, pid file
|
// TODO: Store webserver log, switch uid, log index.php includes, pid file
|
||||||
if ($fork) {
|
if ($fork) {
|
||||||
exec($cmd);
|
exec($cmd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user