本文整理汇总了PHP中Executor::refresh方法的典型用法代码示例。如果您正苦于以下问题:PHP Executor::refresh方法的具体用法?PHP Executor::refresh怎么用?PHP Executor::refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Executor
的用法示例。
在下文中一共展示了Executor::refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex($isForced = false, $isDebug = false)
{
$console = Console::getInstance($isForced, $isDebug);
$terminated = false;
$console->writeLine('Initializing');
// if (Executor::model()->count() >= Settings::getValue(Settings::SIMULTANEOUS_EXECUTORS_LIMIT)) {
// $console->error('Executors limit is reached');
//
// return;
// }
$executor = new Executor();
$executor->save();
$executorTaskSearchCooldown = Settings::getValue(Settings::EXECUTOR_TASK_SEARCH_COOLDOWN);
$executorTaskSearchLimit = Settings::getValue(Settings::EXECUTOR_TASK_SEARCH_LIMIT);
while (!$terminated) {
// Search for task
$console->operationStart('Searching for tasks');
$executor->setStatus(Executor::STATUS_SEARCHING);
try {
$attempt = 1;
while (!$executor->findTask()) {
sleep($executorTaskSearchCooldown);
$console->operationStep();
if ($attempt++ > $executorTaskSearchLimit) {
$console->writeLine('No new tasks');
$executor->delete();
return;
}
}
$executor->refresh();
} catch (Exception $ex) {
$executor->keyword->setStatus(Keyword::STATUS_PENDING);
$executor->setStatus(Executor::STATUS_ERROR);
$console->error($ex->getMessage());
$terminated = true;
continue;
}
$console->operationEnd();
// Start check
$console->writeLine('Checking keyword "' . $executor->keyword->name . '"');
$executor->keyword->setStatus(Keyword::STATUS_IN_PROGRESS);
$executor->setStatus(Executor::STATUS_CHECKING);
$googleSearchEngine = new GoogleSearchEngineIt();
$googleSearchEngine->search($executor->keyword->name);
$sites;
try {
$sites = $googleSearchEngine->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());
$terminated = true;
continue;
}
// Save results
$console->progressStart('Saving results', count($sites));
foreach ($sites as $s) {
$console->progressStep();
$s->keyword_id = $executor->keyword_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->delete();
$console->writeLine('Execution terminated');
return;
}