package cokr.xit.ens;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

import cokr.xit.ens.core.utils.Checks;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@SpringBootApplication
//@Import({QuerydslConfig.class, CodeMapperConfig.class})
@ComponentScan(
//        nameGenerator = CustomBeanNameGenerator.class,
        basePackages = "cokr.xit")
//@EnableAutoConfiguration
@EnableScheduling   
//@EnableWebMvc
//public class ModulePostApplication{
public class ModulePostApplication {
    public static void main(String[] args) {
        log.info("ENS Application load start...");
        if (Checks.isEmpty(System.getProperty("spring.profiles.active"))) {
            log.error("====================================================================");
            log.error(">>>>>>>>>>>>>>         Undefined start option         <<<<<<<<<<<<<<");
            log.error(">>>>>>>>>>>>>> -Dspring.profiles.active=local|dev|prod-traffic/prod-traffic-cheonan/prod-iup <<<<<<<<<<<<<<");
            log.error("============== ENS Application start fail ===============");
            log.error("====================================================================");
            System.exit(-1);
        }
        System.setProperty("ens.active.profile", System.getProperty("spring.profiles.active"));

       
		/*
		SpringApplication.run(ModulePostApplication.class, args);
		*/
        Long begin = System.currentTimeMillis();

       
        SpringApplication application = new SpringApplication(ModulePostApplication.class);
        application.addListeners(new ApplicationPidFileWriter());   
        application.run(args);


        log.info("=========================================================================================");
        log.info("========== ENS Application load Complete :: active profiles - {} ==========", System.getProperty("spring.profiles.active"));
        log.info("=========================================================================================");


        Long end = System.currentTimeMillis();
        System.out.println("====================================================");
        System.out.println("기동 소요시간: " + (end - begin) + "ms");
        System.out.println("====================================================");





        /* multi-thread test */
//		try {
//			MultiThreadSample.example();
//			MultiThreadSample.runnableExample();	
//			MultiThreadSample.callableExample();	
//			MultiThreadSample.completionServiceExample();	
//		} catch (InterruptedException e) {
//			e.printStackTrace();
//		} catch (ExecutionException e) {
//			e.printStackTrace();
//		}

        /* multi-thread return result test */
//		ResultByRunnableExample.main(args);
    }
}
