use Friendica\App;
use Friendica\Core\System;
-use Friendica\Core\Worker;
use Friendica\Core\Config;
use Friendica\Util\Lock;
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, $cmd atrings 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() {
$app_base_themes = array('duepuntozero', 'dispy', 'quattro');
load_hooks();
- // At first check the maximum load. We shouldn't continue with a high load
- if ($a->maxload_reached()) {
- logger('Pre check: maximum load reached, quitting.', LOGGER_DEBUG);
- return;
- }
-
- // We now start the process. This is done after the load check since this could increase the load.
- $a->start_process();
-
$run_cron = (($argc <= 1) || ($argv[1] != "no_cron"));
-
Worker::processQueue($run_cron);
return;
}
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
+use Friendica\Core\Worker;
use Friendica\Util\Lock;
use dba;
self::$up_start = microtime(true);
+ // At first check the maximum load. We shouldn't continue with a high load
+ if ($a->maxload_reached()) {
+ logger('Pre check: maximum load reached, quitting.', LOGGER_DEBUG);
+ return;
+ }
+
+ // We now start the process. This is done after the load check since this could increase the load.
+ $a->start_process();
+
// Kill stale processes every 5 minutes
$last_cleanup = Config::get('system', 'poller_last_cleaned', 0);
if (time() > ($last_cleanup + 300)) {
// Are there fewer workers running as possible? Then fork a new one.
if (!Config::get("system", "worker_dont_fork") && ($queues > ($active + 1)) && ($entries > 1)) {
logger("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG);
- $args = array("include/poller.php", "no_cron");
- get_app()->proc_run($args);
+ self::spawnWorker();
}
}
* @return integer Number of active poller processes
*/
private static function activeWorkers() {
- $workers = q("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'poller.php'");
+ $workers = q("SELECT COUNT(*) AS `processes` FROM `process` WHERE `command` = 'Worker.php'");
return $workers[0]["processes"];
}
self::runCron();
logger('Call poller', LOGGER_DEBUG);
-
- $args = array("include/poller.php", "no_cron");
- get_app()->proc_run($args);
+ self::spawnWorker();
return;
}
self::killStaleWorkers();
}
+ public static function spawnWorker() {
+ $args = array("include/poller.php", "no_cron");
+ get_app()->proc_run($args);
+ }
+
/**
* @brief Adds tasks to the worker queue
*
}
// Now call the poller to execute the jobs that we just added to the queue
- $args = array("include/poller.php", "no_cron");
- get_app()->proc_run($args);
+ self::spawnWorker();
return true;
}