Example #1
0
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);
  }
Example #3
0
<?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');
Example #4
0
/**********************************************************************************
* 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);
?>
Example #5
0
<?php

require_once dirname(dirname(__FILE__)) . '/model/cronmanager/cronmanager.class.php';
$cronmanager = new CronManager($modx);
return $cronmanager->initialize('mgr');
Example #6
0
<?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%" => "", "%darkgrey%" => "", "%blue%" => "", "%lightblue%" => "", "%green%" => "", "%lightgreen%" => "", "%cyan%" => "", "%lightcyan%" => "", "%red%" => "", "%lightred%" => "", "%purple%" => "", "%lightpurple%" => "", "%brown%" => "", "%yellow%" => "", "%lightgray%" => "", "%white%" => "");
            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);
Example #8
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);
 }