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