当前位置: 首页>>代码示例>>PHP>>正文


PHP Executor::stop方法代码示例

本文整理汇总了PHP中Executor::stop方法的典型用法代码示例。如果您正苦于以下问题:PHP Executor::stop方法的具体用法?PHP Executor::stop怎么用?PHP Executor::stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Executor的用法示例。


在下文中一共展示了Executor::stop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionIndex

 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $console->writeLine('Initializing');
     $executor = new Executor();
     // Search for task
     $console->writeLine('Searching for tasks');
     try {
         if (!$executor->findTask()) {
             $console->writeLine('No new tasks');
             return;
         }
     } catch (Exception $ex) {
         $console->error($ex->getMessage());
         return;
     }
     $executor->save();
     // Start check
     $console->writeLine('Checking keyword "' . $executor->keyword->name . '"');
     $executor->keyword->setStatus(Keyword::STATUS_IN_PROGRESS);
     $executor->setStatus(Executor::STATUS_CHECKING);
     // Select search engine
     $searchEngine;
     switch ($executor->keyword->search_engine) {
         case Keyword::SEARCH_ENGINE_GOOGLE:
             $searchEngine = new GoogleSearchEngine();
             break;
         case Keyword::SEARCH_ENGINE_GOOGLE_ES:
             $searchEngine = new GoogleSearchEngineEs();
             break;
         case Keyword::SEARCH_ENGINE_GOOGLE_IT:
             $searchEngine = new GoogleSearchEngineIt();
             break;
         case Keyword::SEARCH_ENGINE_GOOGLE_FR:
             $searchEngine = new GoogleSearchEngineFr();
             break;
         default:
             $errorMessage = 'Unknown search engine: ' . $executor->keyword->search_engine;
             $executor->keyword->setStatus(Keyword::STATUS_PENDING);
             $executor->status = Executor::STATUS_ERROR;
             $executor->message = $errorMessage;
             $executor->update();
             $console->error($errorMessage);
             return;
     }
     $console->writeLine('Using ' . $searchEngine->getSearchEngine() . ' search engine');
     $searchEngine->search($executor->keyword->name);
     $sites;
     try {
         $sites = $searchEngine->getPosition(1, 10);
     } catch (Exception $ex) {
         $executor->keyword->setStatus(Keyword::STATUS_PENDING);
         $executor->status = Executor::STATUS_ERROR;
         $executor->message = $ex->getMessage();
         $executor->update();
         $console->error($ex->getMessage());
         return;
     }
     // Mark previous results as deleted
     $previousSiteCriteria = new CDbCriteria();
     $previousSiteCriteria->alias = 'site';
     $previousSiteCriteria->addCondition('site.keyword_id = :keyword_id');
     $previousSiteCriteria->params = array(':keyword_id' => $executor->keyword_id);
     $previousSiteCriteria->order = 'site.executor_id DESC';
     $previousSiteCriteria->limit = 1;
     if ($previousSite = Site::model()->find($previousSiteCriteria)) {
         Site::model()->updateAll(array('deleted_at' => date(Time::FORMAT_STANDART)), 'executor_id = :executor_id', array(':executor_id' => $previousSite->executor_id));
     }
     // Save new results
     $console->progressStart('Saving results', count($sites));
     foreach ($sites as $s) {
         $console->progressStep();
         $s->keyword_id = $executor->keyword_id;
         $s->executor_id = $executor->id;
         $s->save();
     }
     $console->progressEnd();
     $executor->keyword->setStatus(Keyword::STATUS_CHECKED);
     $executor->setStatus(Executor::STATUS_PENDING);
     if ($executor->status == Executor::STATUS_ERROR) {
         $executor->setStatus(Executor::STATUS_COOLDOWN);
         sleep(Settings::getValue(Settings::ABUSE_COOLDOWN));
     }
     $executor->stop();
     $console->writeLine('Execution terminated');
     return;
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:87,代码来源:ExecutorCommand.php


注:本文中的Executor::stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。