function _w($t, $show_styled = true) { $text = ''; if ($show_styled) { $text = "CRON#" . CronManager::getCronProcessIndex() . " [" . date("d H:i:s") . "] \t - {$t}.\n"; } else { $text = $t; } if (defined('STDOUT')) { fwrite(STDOUT, $text); } else { echo $text; } }
function testRealPerform() { $handle = dirname(__FILE__) . '/TestingCronJob'; registerTestingIni( 'cron.ini', " [cron-job1] handle = {$handle} " ); $cron_manager = new CronManager(); $this->response->expectArgumentsAt(1, 'write', array('I was performed')); $cron_manager->perform($this->response); $contents = $this->_readJobsLastTime(); $this->assertWantedPattern("/^cron-job1 = \d+$/", $contents); }
<?php include 'libs/general.php'; CronManager::init(__FILE__, 10); try { // GET URLs $urls = Providers::get_lead_urls(); _w('Got ' . count($urls) . ' urls'); /// PROCESS URLS foreach ($urls as $url) { // Parse array to url $url_w = urls::create_url($url); _w('Getting url ' . $url_w); // Init content analyzer $ca = ContentAnalyzer::getAnalyzer($url_w); // If content ignored if (!$ca) { _w('ignored'); // Skip continue; } // _w($ca->getOgDescription()); // die; _w('Createing general CA data'); _w('populating search table'); if (Providers::create_search_item($ca)) { _w("search data inserted"); } else { _w("unable to insert search data"); } _w('setting status to indexed');
/********************************************************************************** * Copyright 2004 BIT, Ltd. http://limb-project.com, mailto: support@limb-project.com * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ $site_path = $argv[1]; require_once($site_path . '/setup.php'); require_once(LIMB_DIR . '/class/lib/error/Debug.class.php'); require_once(LIMB_DIR . '/class/core/request/NonbufferedResponse.class.php'); require_once(LIMB_DIR . '/class/lib/cron/CronManager.class.php'); $force = false; if(isset($argv[2]) && $argv[2] == 'force') $force = true; $response = new NonbufferedResponse(); $mgr = new CronManager(); $mgr->perform($response, $force); $response->write(Debug::parseCliConsole()); $response->commit(); exit(0); ?>
<?php require_once dirname(dirname(__FILE__)) . '/model/cronmanager/cronmanager.class.php'; $cronmanager = new CronManager($modx); return $cronmanager->initialize('mgr');
<?php /** * BSD(not a licence) - it's Be Siaat haDishmaya (Translation: With god's help) * * Created by : Yehuda (Daniel) Korotkin * * */ include 'libs/general.php'; CronManager::init(__FILE__, 4); try { // GET URLs $urls = Providers::get_lead_urls(); _w('Got ' . count($urls) . ' urls'); /// PROCESS URLS foreach ($urls as $url) { // Parse array to url $url_w = urls::create_url($url); _w('Getting url ' . $url_w); // Init content analyzer $ca = ContentAnalyzer::getAnalyzer($url_w); // If content ignored if (!$ca) { _w('ignored'); // Skip continue; } _w('Createing general CA data'); Providers::create_search_item($ca); _w('setting status to indexed');
} ## Failsafe if (!class_exists("OutputHandler")) { class OutputHandler { public static function displayOutput($output) { $o = $output; $colors = array("%lightgray%" => "[0;30m", "%darkgrey%" => "[1;30m", "%blue%" => "[0;34m", "%lightblue%" => "[1;34m", "%green%" => "[0;32m", "%lightgreen%" => "[1;32m", "%cyan%" => "[0;36m", "%lightcyan%" => "[1;36m", "%red%" => "[0;31m", "%lightred%" => "[1;31m", "%purple%" => "[0;35m", "%lightpurple%" => "[1;35m", "%brown%" => "[0;33m", "%yellow%" => "[1;33m", "%lightgray%" => "[0;37m", "%white%" => "[1;37m"); foreach ($colors as $key => $value) { $o = str_replace($key, $value, $o); } echo $o; } } } ## Get the correct DB config and connection /*if(GenConfig::LIVE) : $dbh = new DBTasks(DBConfig::DBL_SERVER, DBConfig::DBL_USER, DBConfig::DBL_PASS, DBConfig::DBL_PORT, DBConfig::DBL_DBASE); else : $dbh = new DBTasks(DBConfig::DBD_SERVER, DBConfig::DBD_USER, DBConfig::DBD_PASS, DBConfig::DBD_PORT, DBConfig::DBD_DBASE); endif;*/ if (class_exists("CronManagerDB")) { $dbh = new DBTasks(CronManagerDB::DSN, CronManagerDB::USER, CronManagerDB::PASS, CronManagerDB::DBPORT, CronManagerDB::DBDATABASE); ## Start the application CronManager::DoRun($dbh); SR_Agent::Log(GenConfig::API, SystemReporter::MSG_SUCCESS, "System run completed :)"); } else { OutputHandler::displayOutput("%lightred%FATAL ERROR: Could not load CronManagerDB, quitting...&lightgrey%\n\n"); } exit(0);
/** * init function * @param string $_prefix * @param int $max_processes * @return CronManager */ public static function init($_prefix = 'cron', $max_processes = 1) { CronManager::check_configs(); return CronManager::getSingleton($_prefix, $max_processes); }