X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=bin%2Fdaemon.php;h=e2bad90df59775e74ad4cd96164a84d6df41d13c;hb=c7bbe08a48af9873ec315dc100ed73d4268d44ed;hp=475bafc09de0f03c8c5ae12e4b821ee4f53644e5;hpb=af6dbc654f82225cfc647fe2072662acae388e47;p=friendica.git diff --git a/bin/daemon.php b/bin/daemon.php index 475bafc09d..e2bad90df5 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -12,14 +12,19 @@ use Friendica\Core\Config; use Friendica\Core\Worker; use Friendica\Database\DBA; +// Get options +$shortopts = 'f'; +$longopts = ['foreground']; +$options = getopt($shortopts, $longopts); + // Ensure that daemon.php is executed from the base path of the installation if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) { $directory = dirname($_SERVER["argv"][0]); if (substr($directory, 0, 1) != "/") { - $directory = $_SERVER["PWD"]."/".$directory; + $directory = $_SERVER["PWD"] . "/" . $directory; } - $directory = realpath($directory."/.."); + $directory = realpath($directory . "/.."); chdir($directory); } @@ -29,7 +34,7 @@ require_once "include/dba.php"; $a = new App(dirname(__DIR__)); -if ($a->isInstallMode()) { +if (App\Mode::isInstall()) { die("Friendica isn't properly installed yet.\n"); } @@ -55,7 +60,7 @@ if (in_array("status", $_SERVER["argv"])) { $mode = "status"; } -$foreground = in_array("--foreground", $_SERVER["argv"]); +$foreground = array_key_exists('f', $options) || array_key_exists('foreground', $options); if (!isset($mode)) { die("Please use either 'start', 'stop' or 'status'.\n"); @@ -65,7 +70,11 @@ if (empty($_SERVER["argv"][0])) { die("Unexpected script behaviour. This message should never occur.\n"); } -$pid = @file_get_contents($pidfile); +$pid = null; + +if (is_readable($pidfile)) { + $pid = intval(file_get_contents($pidfile)); +} if (empty($pid) && in_array($mode, ["stop", "status"])) { Config::set('system', 'worker_daemon_mode', false);