package cd.casic.ci.process.engine.scheduler.listener;

import lombok.RequiredArgsConstructor;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author HopeLi
 * @version v1.0
 * @ClassName QuartzStartupListener
 * @Date: 2025/5/27 20:42
 * @Description:
 */

@Component
@RequiredArgsConstructor
public class QuartzStartupListener {
    private final Scheduler scheduler;

    @EventListener(ApplicationReadyEvent.class)
    public void onApplicationReady() throws SchedulerException {
        if (!scheduler.isStarted()) {
            scheduler.start();
            System.out.println("Quartz 调度器已手动启动");
        }
    }
}
