]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker.php
bugfixing ini-loading
[friendica.git] / src / Core / Worker.php
index 3a4be04381b754401d664e561210224fdee3b8e4..00b22c78858c0b06c34ca643174b251fca5a5240 100644 (file)
@@ -5,7 +5,6 @@
 namespace Friendica\Core;
 
 use Friendica\BaseObject;
-use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\Model\Process;
 use Friendica\Util\DateTimeFormat;
@@ -32,6 +31,7 @@ class Worker
         *
         * @param boolean $run_cron Should the cron processes be executed?
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function processQueue($run_cron = true)
        {
@@ -149,6 +149,7 @@ class Worker
         * @brief Returns the number of deferred entries in the worker queue
         *
         * @return integer Number of deferred entries in the worker queue
+        * @throws \Exception
         */
        private static function deferredEntries()
        {
@@ -160,6 +161,7 @@ class Worker
         * @brief Returns the number of non executed entries in the worker queue
         *
         * @return integer Number of non executed entries in the worker queue
+        * @throws \Exception
         */
        private static function totalEntries()
        {
@@ -171,6 +173,7 @@ class Worker
         * @brief Returns the highest priority in the worker queue that isn't executed
         *
         * @return integer Number of active worker processes
+        * @throws \Exception
         */
        private static function highestPriority()
        {
@@ -189,6 +192,7 @@ class Worker
         * @param integer $priority The priority that should be checked
         *
         * @return integer Is there a process running with that priority?
+        * @throws \Exception
         */
        private static function processWithPriorityActive($priority)
        {
@@ -203,6 +207,7 @@ class Worker
         * @param array $queue Workerqueue entry
         *
         * @return boolean "true" if further processing should be stopped
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function execute($queue)
        {
@@ -316,6 +321,7 @@ class Worker
         * @param array   $argv        Array of values to be passed to the function
         * @param boolean $method_call boolean
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function execFunction($queue, $funcname, $argv, $method_call)
        {
@@ -482,6 +488,7 @@ class Worker
         * @brief Checks if the number of database connections has reached a critical limit.
         *
         * @return bool Are more than 3/4 of the maximum connections used?
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function maxConnectionsReached()
        {
@@ -559,6 +566,7 @@ class Worker
        /**
         * @brief fix the queue entry if the worker process died
         * @return void
+        * @throws \Exception
         */
        private static function killStaleWorkers()
        {
@@ -623,6 +631,7 @@ class Worker
         * @brief Checks if the number of active workers exceeds the given limits
         *
         * @return bool Are there too much workers running?
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function tooMuchWorkers()
        {
@@ -727,6 +736,7 @@ class Worker
         * @brief Returns the number of active worker processes
         *
         * @return integer Number of active worker processes
+        * @throws \Exception
         */
        private static function activeWorkers()
        {
@@ -741,6 +751,7 @@ class Worker
         *
         * @param string $highest_priority Returns the currently highest priority
         * @return bool We let pass a slower process than $highest_priority
+        * @throws \Exception
         */
        private static function passingSlow(&$highest_priority)
        {
@@ -793,6 +804,7 @@ class Worker
         *
         * @param boolean $passing_slow Returns if we had passed low priority processes
         * @return boolean Have we found something?
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function findWorkerProcesses(&$passing_slow)
        {
@@ -887,6 +899,7 @@ class Worker
         *
         * @param boolean $passing_slow Returns if we had passed low priority processes
         * @return string SQL statement
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function workerProcess(&$passing_slow)
        {
@@ -922,6 +935,7 @@ class Worker
        /**
         * @brief Removes a workerqueue entry from the current process
         * @return void
+        * @throws \Exception
         */
        public static function unclaimProcess()
        {
@@ -933,6 +947,7 @@ class Worker
        /**
         * @brief Call the front end worker
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function callWorker()
        {
@@ -947,6 +962,7 @@ class Worker
        /**
         * @brief Call the front end worker if there aren't any active
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function executeIfIdle()
        {
@@ -997,6 +1013,7 @@ class Worker
        /**
         * @brief Removes long running worker processes
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function clearProcesses()
        {
@@ -1011,6 +1028,7 @@ class Worker
        /**
         * @brief Runs the cron processes
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        private static function runCron()
        {
@@ -1028,7 +1046,9 @@ class Worker
 
        /**
         * @brief Spawns a new worker
+        * @param bool $do_cron
         * @return void
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function spawnWorker($do_cron = false)
        {
@@ -1053,12 +1073,13 @@ class Worker
         * or: Worker::add(PRIORITY_HIGH, "Notifier", "drop", $drop_id);
         * or: Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "CreateShadowEntry", $post_id);
         *
+        * @return boolean "false" if proc_run couldn't be executed
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @note $cmd and string args are surrounded with ""
         *
         * @hooks 'proc_run'
-        *      array $arr
+        *    array $arr
         *
-        * @return boolean "false" if proc_run couldn't be executed
         */
        public static function add($cmd)
        {
@@ -1070,7 +1091,7 @@ class Worker
 
                $arr = ['args' => $args, 'run_cmd' => true];
 
-               Addon::callHooks("proc_run", $arr);
+               Hook::callAll("proc_run", $arr);
                if (!$arr['run_cmd'] || !count($args)) {
                        return true;
                }
@@ -1187,6 +1208,7 @@ class Worker
         *
         * @brief Remove the active process from the "process" table
         * @return bool
+        * @throws \Exception
         */
        public static function endProcess()
        {
@@ -1198,6 +1220,7 @@ class Worker
         *
         * @brief Set the flag if some job is waiting
         * @param boolean $jobs Is there a waiting job?
+        * @throws \Exception
         */
        public static function IPCSetJobState($jobs)
        {
@@ -1209,6 +1232,7 @@ class Worker
         *
         * @brief Checks if some worker job waits to be executed
         * @return bool
+        * @throws \Exception
         */
        public static function IPCJobsExists()
        {