+
+use Friendica\App;
+use Friendica\BaseObject;
+use Friendica\Core\Config;
+use Friendica\Core\Worker;
+
+// 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 = realpath($directory."/..");
+
+ chdir($directory);
+}
+
+require_once "boot.php";
+require_once "include/dba.php";
+
+$a = new App(dirname(__DIR__));
+BaseObject::setApp($a);
+
+require_once ".htconfig.php";
+dba::connect($db_host, $db_user, $db_pass, $db_data);
+
+Config::load();
+
+if (!isset($pidfile)) {
+ die('Please specify a pid file in the variable $pidfile in the .htconfig.php. For example:'."\n".
+ '$pidfile = "/path/to/daemon.pid";'."\n");