Merge pull request #3625 from Icinga/bugfix/web-serve
icingacli web serve: preserve console colors and avoid redundand process
This commit is contained in:
commit
ed21fe280e
|
@ -55,20 +55,12 @@ class WebCommand extends Command
|
||||||
$this->forkAndExit();
|
$this->forkAndExit();
|
||||||
}
|
}
|
||||||
echo "Serving Icinga Web 2 from directory $documentRoot and listening on $socket\n";
|
echo "Serving Icinga Web 2 from directory $documentRoot and listening on $socket\n";
|
||||||
$cmd = sprintf(
|
|
||||||
'%s -S %s -t %s %s',
|
|
||||||
readlink('/proc/self/exe'),
|
|
||||||
$socket,
|
|
||||||
$documentRoot,
|
|
||||||
Icinga::app()->getLibraryDir('/Icinga/Application/webrouter.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) {
|
pcntl_exec(
|
||||||
exec($cmd);
|
readlink('/proc/self/exe'),
|
||||||
} else {
|
['-S', $socket, '-t', $documentRoot, Icinga::app()->getLibraryDir('/Icinga/Application/webrouter.php')]
|
||||||
passthru($cmd);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stopAction()
|
public function stopAction()
|
||||||
|
@ -93,6 +85,17 @@ class WebCommand extends Command
|
||||||
// pcntl_wait($status);
|
// pcntl_wait($status);
|
||||||
} else {
|
} else {
|
||||||
// child
|
// child
|
||||||
|
|
||||||
|
// Replace console with /dev/null by first freeing the (lowest possible) FDs 0, 1 and 2
|
||||||
|
// and then opening /dev/null once for every one of them (open(2) chooses the lowest free FD).
|
||||||
|
|
||||||
|
fclose(STDIN);
|
||||||
|
fclose(STDOUT);
|
||||||
|
fclose(STDERR);
|
||||||
|
|
||||||
|
fopen('/dev/null', 'rb');
|
||||||
|
fopen('/dev/null', 'wb');
|
||||||
|
fopen('/dev/null', 'wb');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue