return ((x($a->config, 'max_import_size')) ? $a->config['max_import_size'] : 0 );
}
-/**
- * @brief compatibilty wrapper for Worker::add function
- *
- * @param (integer|array) priority or parameter array, strings are deprecated and are ignored
- *
- * @return boolean "false" if proc_run couldn't be executed
- */
-function proc_run()
-{
- $proc_args = func_get_args();
- call_user_func_array('Friendica\Core\Worker::add', $proc_args);
-}
function current_theme()
{
return($database);
}
-
-
-/*
- * run from command line
- */
-function dbstructure_run(&$argv, &$argc) {
- global $a;
-
- if (empty($a)) {
- $a = new App(dirname(__DIR__));
- }
-
- @include ".htconfig.php";
- require_once "include/dba.php";
- dba::connect($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
-
- if ($argc == 2) {
- switch ($argv[1]) {
- case "dryrun":
- update_structure(true, false);
- return;
- case "update":
- update_structure(true, true);
-
- $build = Config::get('system','build');
- if (!x($build)) {
- Config::set('system', 'build', DB_UPDATE_VERSION);
- $build = DB_UPDATE_VERSION;
- }
-
- $stored = intval($build);
- $current = intval(DB_UPDATE_VERSION);
-
- // run any left update_nnnn functions in update.php
- for ($x = $stored; $x < $current; $x ++) {
- $r = run_update_function($x);
- if (!$r) {
- break;
- }
- }
-
- Config::set('system','build',DB_UPDATE_VERSION);
- return;
- case "dumpsql":
- print_structure(db_definition());
- return;
- case "toinnodb":
- convert_to_innodb();
- return;
- }
- }
-
-
- // print help
- echo $argv[0]." <command>\n";
- echo "\n";
- echo "Commands:\n";
- echo "dryrun show database update schema queries without running them\n";
- echo "update update database schema\n";
- echo "dumpsql dump database schema\n";
- echo "toinnodb convert all tables from MyISAM to InnoDB\n";
- return;
-
-}
-
-if (array_search(__FILE__,get_included_files())===0) {
- dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);
- killme();
-}
+++ /dev/null
-<?php
-use Friendica\App;
-use Friendica\Core\Worker;
-use Friendica\Core\Config;
-
-// Ensure that poller.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__));
-
-require_once ".htconfig.php";
-dba::connect($db_host, $db_user, $db_pass, $db_data);
-unset($db_host, $db_user, $db_pass, $db_data);
-
-Config::load();
-
-// Check the database structure and possibly fixes it
-check_db(true);
-
-// Quit when in maintenance
-if (Config::get('system', 'maintenance', true)) {
- return;
-}
-
-$a->set_baseurl(Config::get('system', 'url'));
-
-load_hooks();
-
-$run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
-Worker::processQueue($run_cron);
-
-Worker::unclaimProcess();
-
-$a->end_process();
-
-killme();
-
--- /dev/null
+<?php
+/**
+ * @file util/daemon.php
+ * @brief Run the poller from a daemon.
+ *
+ * This script was taken from http://php.net/manual/en/function.pcntl-fork.php
+ */
+function shutdown() {
+ posix_kill(posix_getpid(), SIGHUP);
+}
+
+if (in_array("start", $_SERVER["argv"])) {
+ $mode = "start";
+}
+
+if (in_array("stop", $_SERVER["argv"])) {
+ $mode = "stop";
+}
+
+if (in_array("status", $_SERVER["argv"])) {
+ $mode = "status";
+}
+
+if (!isset($mode)) {
+ die("Please use either 'start', 'stop' or 'status'.\n");
+}
+
+@include(".htconfig.php");
+
+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");
+}
+
+if (in_array($mode, array("stop", "status"))) {
+ $pid = @file_get_contents($pidfile);
+
+ if (!$pid) {
+ die("Pidfile wasn't found. Is the daemon running?\n");
+ }
+}
+
+if ($mode == "status") {
+ if (posix_kill($pid, 0)) {
+ die("Daemon process $pid is running.\n");
+ }
+
+ unlink($pidfile);
+
+ die("Daemon process $pid isn't running.\n");
+}
+
+if ($mode == "stop") {
+ posix_kill($pid, SIGTERM);
+
+ unlink($pidfile);
+
+ die("Worker daemon process $pid was killed.\n");
+}
+
+echo "Starting worker daemon.\n";
+
+if (isset($a->config['php_path'])) {
+ $php = $a->config['php_path'];
+} else {
+ $php = "php";
+}
+
+// Switch over to daemon mode.
+if ($pid = pcntl_fork())
+ return; // Parent
+
+fclose(STDIN); // Close all of the standard
+fclose(STDOUT); // file descriptors as we
+fclose(STDERR); // are running as a daemon.
+
+register_shutdown_function('shutdown');
+
+if (posix_setsid() < 0)
+ return;
+
+if ($pid = pcntl_fork())
+ return; // Parent
+
+$pid = getmypid();
+file_put_contents($pidfile, $pid);
+
+// Now running as a daemon.
+while (true) {
+ // Just to be sure that this script really runs endlessly
+ set_time_limit(0);
+
+ // Call the poller
+ $cmdline = $php.' include/poller.php';
+
+ exec($cmdline);
+
+ // Now sleep for 5 minutes
+ sleep(300);
+}
--- /dev/null
+<?php
+/**
+ * @file scripts/dbstructure.php
+ * @brief Does database updates from the command line
+ */
+
+require_once 'include/dbstructure.php';
+
+use Friendica\App;
+
+$a = new App(dirname(__DIR__));
+
+@include ".htconfig.php";
+require_once "include/dba.php";
+dba::connect($db_host, $db_user, $db_pass, $db_data);
+unset($db_host, $db_user, $db_pass, $db_data);
+
+if ($_SERVER["argc"] == 2) {
+ switch ($_SERVER["argv"][1]) {
+ case "dryrun":
+ update_structure(true, false);
+ return;
+ case "update":
+ update_structure(true, true);
+
+ $build = Config::get('system','build');
+ if (!x($build)) {
+ Config::set('system', 'build', DB_UPDATE_VERSION);
+ $build = DB_UPDATE_VERSION;
+ }
+
+ $stored = intval($build);
+ $current = intval(DB_UPDATE_VERSION);
+
+ // run any left update_nnnn functions in update.php
+ for ($x = $stored; $x < $current; $x ++) {
+ $r = run_update_function($x);
+ if (!$r) {
+ break;
+ }
+ }
+
+ Config::set('system','build',DB_UPDATE_VERSION);
+ return;
+ case "dumpsql":
+ print_structure(db_definition());
+ return;
+ case "toinnodb":
+ convert_to_innodb();
+ return;
+ }
+}
+
+// print help
+echo $_SERVER["argv"][0]." <command>\n";
+echo "\n";
+echo "Commands:\n";
+echo "dryrun show database update schema queries without running them\n";
+echo "update update database schema\n";
+echo "dumpsql dump database schema\n";
+echo "toinnodb convert all tables from MyISAM to InnoDB\n";
+killme();
+
--- /dev/null
+<?php
+use Friendica\App;
+use Friendica\Core\Worker;
+use Friendica\Core\Config;
+
+// Ensure that poller.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__));
+
+require_once ".htconfig.php";
+dba::connect($db_host, $db_user, $db_pass, $db_data);
+unset($db_host, $db_user, $db_pass, $db_data);
+
+Config::load();
+
+// Check the database structure and possibly fixes it
+check_db(true);
+
+// Quit when in maintenance
+if (Config::get('system', 'maintenance', true)) {
+ return;
+}
+
+$a->set_baseurl(Config::get('system', 'url'));
+
+load_hooks();
+
+$run_cron = (($_SERVER["argc"] <= 1) || ($_SERVER["argv"][1] != "no_cron"));
+Worker::processQueue($run_cron);
+
+Worker::unclaimProcess();
+
+$a->end_process();
+
+killme();
+
}
public static function spawnWorker() {
- $args = array("include/poller.php", "no_cron");
+ $args = array("scripts/worker.php", "no_cron");
get_app()->proc_run($args);
}
+++ /dev/null
-<?php
-/**
- * @file util/daemon.php
- * @brief Run the poller from a daemon.
- *
- * This script was taken from http://php.net/manual/en/function.pcntl-fork.php
- */
-function shutdown() {
- posix_kill(posix_getpid(), SIGHUP);
-}
-
-if (in_array("start", $_SERVER["argv"])) {
- $mode = "start";
-}
-
-if (in_array("stop", $_SERVER["argv"])) {
- $mode = "stop";
-}
-
-if (in_array("status", $_SERVER["argv"])) {
- $mode = "status";
-}
-
-if (!isset($mode)) {
- die("Please use either 'start', 'stop' or 'status'.\n");
-}
-
-@include(".htconfig.php");
-
-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");
-}
-
-if (in_array($mode, array("stop", "status"))) {
- $pid = @file_get_contents($pidfile);
-
- if (!$pid) {
- die("Pidfile wasn't found. Is the daemon running?\n");
- }
-}
-
-if ($mode == "status") {
- if (posix_kill($pid, 0)) {
- die("Daemon process $pid is running.\n");
- }
-
- unlink($pidfile);
-
- die("Daemon process $pid isn't running.\n");
-}
-
-if ($mode == "stop") {
- posix_kill($pid, SIGTERM);
-
- unlink($pidfile);
-
- die("Worker daemon process $pid was killed.\n");
-}
-
-echo "Starting worker daemon.\n";
-
-if (isset($a->config['php_path'])) {
- $php = $a->config['php_path'];
-} else {
- $php = "php";
-}
-
-// Switch over to daemon mode.
-if ($pid = pcntl_fork())
- return; // Parent
-
-fclose(STDIN); // Close all of the standard
-fclose(STDOUT); // file descriptors as we
-fclose(STDERR); // are running as a daemon.
-
-register_shutdown_function('shutdown');
-
-if (posix_setsid() < 0)
- return;
-
-if ($pid = pcntl_fork())
- return; // Parent
-
-$pid = getmypid();
-file_put_contents($pidfile, $pid);
-
-// Now running as a daemon.
-while (true) {
- // Just to be sure that this script really runs endlessly
- set_time_limit(0);
-
- // Call the poller
- $cmdline = $php.' include/poller.php';
-
- exec($cmdline);
-
- // Now sleep for 5 minutes
- sleep(300);
-}