From: Michael Date: Sun, 19 Nov 2017 21:21:54 +0000 (+0000) Subject: We now are having a "scripts" folder X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cabfcfc904ed782f09c91ed35da6b2ad65ce0f09;p=friendica.git We now are having a "scripts" folder --- diff --git a/boot.php b/boot.php index 402273bddf..0364bd4e72 100644 --- a/boot.php +++ b/boot.php @@ -1064,18 +1064,6 @@ function get_max_import_size() 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() { diff --git a/include/dbstructure.php b/include/dbstructure.php index 1df82b1bed..dde3dc6f18 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1757,73 +1757,3 @@ function db_definition() { 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]." \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(); -} diff --git a/include/poller.php b/include/poller.php deleted file mode 100644 index 6fcf4c7f41..0000000000 --- a/include/poller.php +++ /dev/null @@ -1,49 +0,0 @@ -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(); - diff --git a/scripts/daemon.php b/scripts/daemon.php new file mode 100644 index 0000000000..4accef3960 --- /dev/null +++ b/scripts/daemon.php @@ -0,0 +1,100 @@ +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); +} diff --git a/scripts/dbstructure.php b/scripts/dbstructure.php new file mode 100644 index 0000000000..cf14c929f6 --- /dev/null +++ b/scripts/dbstructure.php @@ -0,0 +1,63 @@ +\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(); + diff --git a/scripts/worker.php b/scripts/worker.php new file mode 100644 index 0000000000..6fcf4c7f41 --- /dev/null +++ b/scripts/worker.php @@ -0,0 +1,49 @@ +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(); + diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 9e69d4173a..e949ff2da8 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -912,7 +912,7 @@ class Worker { } public static function spawnWorker() { - $args = array("include/poller.php", "no_cron"); + $args = array("scripts/worker.php", "no_cron"); get_app()->proc_run($args); } diff --git a/util/daemon.php b/util/daemon.php deleted file mode 100644 index 4accef3960..0000000000 --- a/util/daemon.php +++ /dev/null @@ -1,100 +0,0 @@ -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); -}