fix(timer): call 任务执行加异常捕获防止单任务崩溃定时器

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
augushong
2026-07-17 23:33:41 +08:00
parent ccb7540356
commit e4965e05b6

View File

@@ -299,8 +299,13 @@ class TimerBase extends Command
continue; continue;
} }
Cache::tag($cache_tag)->set($cache_key, time()); Cache::tag($cache_tag)->set($cache_key, time());
call_user_func($call_item['target']); try {
$output->writeln(date('Y-m-d H:i:s') . ': call function ' . $name . ' finished'); call_user_func($call_item['target']);
$output->writeln(date('Y-m-d H:i:s') . ': call function ' . $name . ' finished');
} catch (\Throwable $th) {
$output->writeln(date('Y-m-d H:i:s') . ': call function ' . $name . ' error: ' . $th->getMessage());
Log::error('timer call [' . $name . '] error: ' . $th->getMessage());
}
} }
if ($input->hasOption('temp')) { if ($input->hasOption('temp')) {