]> git.mxchange.org Git - friendica.git/blobdiff - bin/daemon.php
Catch HTTPExceptions in App::runFrontend()
[friendica.git] / bin / daemon.php
index bf82912ee2abc91df456aa104409284fb2df4359..e60e32b19ec0900caf57450c0d7c09794d69d2d3 100755 (executable)
@@ -9,13 +9,13 @@
 
 use Friendica\App;
 use Friendica\Core\Config;
+use Friendica\Core\Logger;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 
 // Get options
-$shortopts  = '';
-$shortopts .= 'f';
-$longopts = [ 'foreground' ];
+$shortopts = 'f';
+$longopts = ['foreground'];
 $options = getopt($shortopts, $longopts);
 
 // Ensure that daemon.php is executed from the base path of the installation
@@ -30,21 +30,25 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
        chdir($directory);
 }
 
-require_once "boot.php";
-require_once "include/dba.php";
+require dirname(__DIR__) . '/vendor/autoload.php';
 
 $a = new App(dirname(__DIR__));
 
-if ($a->isInstallMode()) {
+if ($a->getMode()->isInstall()) {
        die("Friendica isn't properly installed yet.\n");
 }
 
 Config::load();
 
 if (empty(Config::get('system', 'pidfile'))) {
-       die('Please set system.pidfile in config/local.ini.php. For example:'."\n".
-               '[system]'."\n".
-               'pidfile = /path/to/daemon.pid'."\n");
+       die(<<<TXT
+Please set system.pidfile in config/local.config.php. For example:
+    
+    'system' => [ 
+        'pidfile' => '/path/to/daemon.pid',
+    ],
+TXT
+    );
 }
 
 $pidfile = Config::get('system', 'pidfile');
@@ -98,7 +102,7 @@ if ($mode == "stop") {
 
        unlink($pidfile);
 
-       logger("Worker daemon process $pid was killed.", LOGGER_DEBUG);
+       Logger::log("Worker daemon process $pid was killed.", Logger::DEBUG);
 
        Config::set('system', 'worker_daemon_mode', false);
        die("Worker daemon process $pid was killed.\n");
@@ -108,7 +112,7 @@ if (!empty($pid) && posix_kill($pid, 0)) {
        die("Daemon process $pid is already running.\n");
 }
 
-logger('Starting worker daemon.', LOGGER_DEBUG);
+Logger::log('Starting worker daemon.', Logger::DEBUG);
 
 if (!$foreground) {
        echo "Starting worker daemon.\n";
@@ -156,7 +160,7 @@ $last_cron = 0;
 // Now running as a daemon.
 while (true) {
        if (!$do_cron && ($last_cron + $wait_interval) < time()) {
-               logger('Forcing cron worker call.', LOGGER_DEBUG);
+               Logger::log('Forcing cron worker call.', Logger::DEBUG);
                $do_cron = true;
        }
 
@@ -170,7 +174,7 @@ while (true) {
                $last_cron = time();
        }
 
-       logger("Sleeping", LOGGER_DEBUG);
+       Logger::log("Sleeping", Logger::DEBUG);
        $start = time();
        do {
                $seconds = (time() - $start);
@@ -187,10 +191,10 @@ while (true) {
 
        if ($timeout) {
                $do_cron = true;
-               logger("Woke up after $wait_interval seconds.", LOGGER_DEBUG);
+               Logger::log("Woke up after $wait_interval seconds.", Logger::DEBUG);
        } else {
                $do_cron = false;
-               logger("Worker jobs are calling to be forked.", LOGGER_DEBUG);
+               Logger::log("Worker jobs are calling to be forked.", Logger::DEBUG);
        }
 }