public static function Start() { // Setup log file self::$LOG = DATA_DIR . '/' . basename(self::$LOG); if (!file_exists(self::$LOG)) { File::Create(self::$LOG); } // Make sure not marked to stop Cache_MySQL::Cache(self::$CACHE_STOP, 0); // Start it up, if not already running if (!self::IsRunning()) { $si = ServerInfo::GetCached(); $script = dirname(realpath(__FILE__)) . '/' . self::$SCRIPT; File::Create(self::$LOG); shell_exec($si->binaries[ServerInfo::BIN_PHP] . ' -q ' . $script . ' ' . self::ARGUMENT . ' >>' . escapeshellarg(self::$LOG) . ' 2>&1 &'); } }
/** * Returns true if the Asynchronous Queue Processor is enabled and is * functioning properly. * * @return boolean Is the Asynchronous Queue Processor is enabled and * functioning properly? */ public static function isSchedulerEnabled() { return QueueProcessor::isActive(); }
// Register module specific tasks $taskedModules = ModuleUtility::registerModuleTasks(); print_r($taskedModules); // Execute the next appropriate (if available) queue and return a status code $retVal = QueueProcessor::startNextTask(); // Mark the queue processor last-run time touch(QUEUE_STATUS_FILE); if (file_exists(QUEUE_CLEANUP_FILE)) { $lastCleanupTime = @filemtime(QUEUE_CLEANUP_FILE); } else { $lastCleanupTime = 0; } if (time() - $lastCleanupTime > QUEUE_CLEANUP_HOURS * 60 * 60 || !$lastCleanupTime) { @touch(QUEUE_CLEANUP_FILE); QueueProcessor::cleanUpErroredTasks(); QueueProcessor::cleanUpOldQueues(); } echo "CATS Queue Processor status: "; switch ($retVal) { case TASKRET_ERROR: echo "ERROR"; break; case TASKRET_FAILURE: echo "FAILURE"; break; case TASKRET_NO_TASKS: echo "NO TASKS"; break; case TASKRET_SUCCESS: echo "SUCCESS"; break;
* * * The contents of this file are subject to the CATS Public License * Version 1.1a (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.catsone.com/. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is "CATS Standard Edition". * * The Initial Developer of the Original Code is Cognizo Technologies, Inc. * Portions created by the Initial Developer are Copyright (C) 2005 - 2007 * (or from the year in which this file was created to the year 2007) by * Cognizo Technologies, Inc. All Rights Reserved. * * * Constants for the standalone QueueProcessor and QueueProcessor tasks. * * * $Id: tasks.php 3558 2007-11-11 22:44:14Z will $ */ // Add a new task to the queue processor using the following line as an example. // Use the modules/queue/tasks/SampleRecurring.php file as a template // QueueProcessor::registerRecurringTask('SampleRecurring'); /*************** ADD NEW TASKS HERE (scheduling is set inside the task) ****************/ QueueProcessor::registerRecurringTask('./modules/calendar/tasks/Reminders.php');
public function setResponse($msg) { QueueProcessor::setTaskResponse($this->taskID, $msg); }
* Version 1.1a (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.catsone.com/. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is "CATS Standard Edition". * * The Initial Developer of the Original Code is Cognizo Technologies, Inc. * Portions created by the Initial Developer are Copyright (C) 2005 - 2007 * (or from the year in which this file was created to the year 2007) by * Cognizo Technologies, Inc. All Rights Reserved. * * * Constants for the standalone QueueProcessor and QueueProcessor tasks. * * * $Id: tasks.php 3633 2007-11-16 16:41:47Z andrew $ */ // Add a new task to the queue processor using the following line as an example. // Use the modules/queue/tasks/SampleRecurring.php file as a template // QueueProcessor::registerRecurringTask('SampleRecurring'); /*************** ADD NEW TASKS HERE (scheduling is set inside the task) ****************/ QueueProcessor::registerRecurringTask('./modules/queue/tasks/CleanExceptions.php'); // Sphinx task for updating deltas, rebuilding of the index, etc. if (ENABLE_SPHINX) { //QueueProcessor::registerRecurringTask('./modules/queue/tasks/Sphinx.php'); }
require_once 'lib/daemon/System/Daemon.php'; require_once 'queue_process.php'; require_once 'config.php'; // Bare minimum setup System_Daemon::setOption("appName", "FriendConsumerDaemon"); System_Daemon::setOption("authorEmail", "*****@*****.**"); System_Daemon::setOption("usePEAR", false); System_Daemon::setOption("appDir", dirname(__FILE__)); System_Daemon::log(System_Daemon::LOG_INFO, "Daemon not yet started so " . "this will be written on-screen"); // Spawn Deamon! System_Daemon::start(); System_Daemon::log(System_Daemon::LOG_INFO, "Daemon: '" . System_Daemon::getOption("appName") . "' spawned! This will be written to " . System_Daemon::getOption("logLocation")); // Your normal PHP code goes here. Only the code will run in the background // so you can close your terminal session, and the application will // still run. $qp = new QueueProcessor(); $lastCheck = 0; // This variable gives your own code the ability to breakdown the daemon: $runningOkay = true; // While checks on 3 things in this case: // - That the Daemon Class hasn't reported it's dying // - That your own code has been running Okay // - That we're not executing more than 3 runs while (!System_Daemon::isDying() && $runningOkay) { $lastCheck = time(); $qp->process(); // Wait until ready for next check while (time() - $lastCheck < 5) { System_Daemon::iterate(2); } }
* compliance with the License. You may obtain a copy of the License at * http://www.catsone.com/. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is "CATS Standard Edition". * * The Initial Developer of the Original Code is Cognizo Technologies, Inc. * Portions created by the Initial Developer are Copyright (C) 2005 - 2007 * (or from the year in which this file was created to the year 2007) by * Cognizo Technologies, Inc. All Rights Reserved. * * * Constants for the standalone QueueProcessor and QueueProcessor tasks. * * * $Id: tasks.php 3673 2007-11-21 20:47:47Z andrew $ */ // Add a new task to the queue processor using the following line as an example. // Use the modules/queue/tasks/SampleRecurring.php file as a template // QueueProcessor::registerRecurringTask('SampleRecurring'); /*************** ADD NEW TASKS HERE (scheduling is set inside the task) ****************/ include_once 'config.php'; include_once './modules/asp/lib/ASPUtility.php'; QueueProcessor::registerRecurringTask('CleanExceptions'); // Sphinx task for updating deltas, rebuilding of the index, etc. //if (ENABLE_SPHINX) // QueueProcessor::registerRecurringTask('Sphinx');