Ver código fonte

增加image2超时重置逻辑

lh 1 dia atrás
pai
commit
e93f45314f

+ 9 - 0
app/Console/Commands/CheckImageGenerationTasksCommand.php

@@ -33,6 +33,15 @@ class CheckImageGenerationTasksCommand extends Command
     {
         dLog('command')->info('开始检查图片生成任务状态...');
 
+        // 将指定时间点之前的image2生成中图片任务设置为待生成以供重试(防止接口超时返回变成死任务)
+        $time_ago = date('Y-m-d H:i:s', strtotime('-10 minutes'));
+        $timeout_count = DB::table('mp_generate_pic_tasks')->whereNotNull('started_at')->where('started_at', '<', $time_ago)->where('status', 'processing')
+            ->whereIn('model', BaseConst::GPT_IMAGE2_MODELS)->update([
+                'started_at'    => null,
+                'status'        => 'pending',
+            ]);
+        dLog('command')->info('image2超时重置任务个数: '.$timeout_count);
+
         // 执行50s
         $time_start = time();
         try {