public function run(&$params)
 {
     if (C('UPGRADE_NOTICE_ON') && (!S('think_upgrade_interval') || C('UPGRADE_NOTICE_DEBUG'))) {
         if (IS_SAE && C('UPGRADE_NOTICE_QUEUE') && !isset($_POST['think_upgrade_queque'])) {
             $queue = new SaeTaskQueue(C('UPGRADE_NOTICE_QUEUE'));
             $queue->addTask('http://' . $_SERVER['HTTP_HOST'] . __APP__, 'think_upgrade_queque=1');
             if (!$queue->push()) {
                 trace('升级提醒队列执行失败,错误原因:' . $queue->errmsg(), '升级通知出错', 'NOTIC', true);
             }
             return;
         }
         $akey = C('UPGRADE_NOTICE_AKEY', null, '');
         $skey = C('UPGRADE_NOTICE_SKEY', null, '');
         $this->accesskey_ = $akey ? $akey : (defined('SAE_ACCESSKEY') ? SAE_ACCESSKEY : '');
         $this->secretkey_ = $skey ? $skey : (defined('SAE_SECRETKEY') ? SAE_SECRETKEY : '');
         $current_version = C('UPGRADE_CURRENT_VERSION', null, 0);
         //读取接口
         $info = $this->send('http://sinaclouds.sinaapp.com/thinkapi/upgrade.php?v=' . $current_version);
         if ($info['version'] != $current_version) {
             if ($this->send_sms($info['msg'])) {
                 trace($info['msg'], '升级通知成功', 'NOTIC', true);
             }
             //发送升级短信
         }
         S('think_upgrade_interval', true, C('UPGRADE_NOTICE_CHECK_INTERVAL', null, 604800));
     }
 }
예제 #2
0
function TimingTask()
{
    // load urls
    $mysql = new SaeMysql();
    $sql = "SELECT url FROM `url`";
    $data = $mysql->getData( $sql );
    $mysql->closeDb();

    $queue = new SaeTaskQueue('task_queue_0_2');
    $array = array();
    for($i = 0; $i < sizeof($data); ++$i)
    {
        //$array[] = array('url'=>"http://urlwatcher.sinaapp.com/url_watch.php", "postdata"=>"target=".$data[$i], "prior"=>true);
        $array[] = array('url'=>"http://urlwatcher.sinaapp.com/url_watch.php?target=" . $data[$i]["url"], "postdata"=>NULL, "prior"=>true);
    }
    
    $queue->addTask($array);

    $ret = $queue->push();
    if ($ret === false)
    {
        var_dump($queue->errno(), $queue->errmsg());
        echo "Failed.";
    }
    else
    {    
        echo "Success.";
        print_r($array);
    }
}
예제 #3
0
 public function tq()
 {
     $t = new SaeTaskQueue("test");
     $t->addTask("http://" . $_SERVER['HTTP_HOST'] . __URL__ . "/tq_test1");
     //添加列队任务1
     $t->addTask("http://" . $_SERVER['HTTP_HOST'] . __URL__ . "/tq_test2", "k1=v1&k2=v2", true);
     //添加列队任务2
     if (!$t->push()) {
         echo '出错:' . $t->errmsg();
     } else {
         if (IS_SAE) {
             echo '请查看SAE的日志中心执行,选择类型为debug';
         } else {
             echo '执行成功!请查看[' . LOG_PATH . 'sae_debug.log' . ']文件中的日志';
         }
     }
 }
예제 #4
0
파일: Ysu.php 프로젝트: yang22t/ysu
 public function timerAction()
 {
     $tasks = array();
     $list = Ysu_LibraryModel::select_all();
     if (empty($list)) {
         echo 'no task';
         exit;
     }
     $queue = new SaeTaskQueue('ysulibrary');
     foreach ($list as $v) {
         $tasks[] = array('url' => '/ysu/task', 'postdata' => 'param=' . json_encode($v));
     }
     $queue->addTask($tasks);
     $ret = $queue->push();
     if ($ret === false) {
         var_dump($queue->errno(), $queue->errmsg());
     } else {
         echo 'total task: ' . count($list);
     }
 }
예제 #5
0
function cron($start = 0, $limit = 70, $schema_id = 0)
{
    global $_db;
    $where = "WHERE `status` = 'on'";
    if ($schema_id > 0) {
        $where .= " AND schema_id = {$schema_id}";
        $start = 0;
        $limit = 1;
    }
    $sql = "SELECT * FROM `schemas` {$where} LIMIT {$start},{$limit}";
    $schemas = $_db->get_results($sql);
    fetch_web($schemas);
    return count($schemas);
}
if (is_numeric($_REQUEST['start'])) {
    echo cron($_REQUEST['start'], $_REQUEST['limit']);
} elseif (empty($_REQUEST['start'])) {
    $total = $_db->get_var("SELECT count(*) FROM `schemas` WHERE `status` = 'on'");
    $queue = new SaeTaskQueue("cron_tail");
    $array = array();
    for ($i = 0; $i <= $total + 70; $i += 70) {
        $array[] = array('url' => "http://pickcat.sinaapp.com/cron.php", "postdata" => "start={$i}&limit=70");
    }
    $queue->addTask($array);
    $ret = $queue->push();
    if ($ret === false) {
        var_dump($queue->errno(), $queue->errmsg());
    } else {
        echo 'true';
    }
}