$cacheKey = 'apRecalculateTask';
$cache = Yii::$app->cache;
$task = $cache->get($cacheKey);
+ if ($task) {
+ $this->stdout("Задача время {$task['startTime']}\n");
+ }
$scriptLauncherLog = ScriptLauncherLog::find()
- ->andWhere(['name' => "taskApRecalculate"])
- ->orderBy(['created_at' => SORT_DESC])
- ->asArray()
- ->limit(1)
- ->one();
- if ($scriptLauncherLog && $scriptLauncherLog['active'] == 1 && $scriptLauncherLog['status'] == 1) {
- //$task = json_decode($scriptLauncherLog['context'], true );
- // $cache->delete($cacheKey);
- $this->stdout("Задача уже запущена {$task['startTime']}\n");
- return ExitCode::OK;
- }
+ ->andWhere(['name' => "taskApRecalculate"])
+ ->orderBy(['created_at' => SORT_DESC])
+ ->asArray()
+ ->limit(1)
+ ->one();
+ if ($scriptLauncherLog && $scriptLauncherLog['active'] == 1 && $scriptLauncherLog['status'] == 1) {
+ //$task = json_decode($scriptLauncherLog['context'], true );
+ $cache->delete($cacheKey);
+ $this->stdout("Задача уже запущена {$task['startTime']}\n");
+ return ExitCode::OK;
+ }
//$this->stdout(json_encode($task, JSON_UNESCAPED_UNICODE));
$log->message = 'Finished successfully';
$log->progress = 100;
$log->active = 0;
- $log->progress = 100;
$log->date_finish = date('Y-m-d H:i:s');
$log->status = 2;
if (!$log->save()) {
Yii::error(json_encode($log->getErrors(), JSON_UNESCAPED_UNICODE));
+ $this->stdout(json_encode($log->getErrors()));
LogService::apiErrorLog(json_encode(["error_id" => 8, "error" => $log->getErrors()], JSON_UNESCAPED_UNICODE));
}
$cache->delete($cacheKey);