// invoked in worker
think.beforeStartServer(async () => {
  // 恢复中断的导出任务
  try {
    const taskModel = think.model('export_task');
    const recovered = await taskModel.recoverStuckTasks();
    if (recovered) {
      think.logger.info(`[Bootstrap] 恢复了 ${recovered} 个中断的导出任务`);
    }
    // 处理待执行的任务
    const pending = await taskModel.getPendingTask();
    if (!think.isEmpty(pending)) {
      think.logger.info('[Bootstrap] 发现待处理的导出任务，启动处理');
      const exportService = think.service('export');
      setImmediate(() => exportService.startProcessing());
    }
  } catch (e) {
    think.logger.error('[Bootstrap] 导出任务恢复失败:', e);
  }
});
