package cn.sagacloud.server.scheduler

import cn.sagacloud.server.Server
import org.springframework.boot.ApplicationArguments
import org.springframework.boot.ApplicationRunner
import org.springframework.stereotype.Component
import kotlin.concurrent.thread

/**
 *
 *
 * @author jxing
 */
@Component
open class TimedTaskRunner : ApplicationRunner {

    var server : Server? = null
    /**
     * SpringApplication启动后执行的回调函数。
     * 在此启动调度器
     *
     * @param   args        启动参数
     */
    override fun run(args: ApplicationArguments?) {
        thread(start = true) {
            if(server == null){
                server = Server()
                server!!.start()
            }
        } // thread
    } // Fun run()
} // Class AppRunner