package com.qqchen.deploy.backend.system.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * 系统版本发布配置
 */
@Configuration
public class SystemReleaseConfig {

    /**
     * 配置任务调度器
     * 用于延迟执行系统维护任务
     */
    @Bean
    public TaskScheduler systemMaintenanceTaskScheduler() {
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setPoolSize(5);
        scheduler.setThreadNamePrefix("system-maintenance-");
        scheduler.setWaitForTasksToCompleteOnShutdown(false);
        scheduler.setAwaitTerminationSeconds(0);
        scheduler.initialize();
        return scheduler;
    }
}
