package com.ecep.contract;

import java.time.Duration;
import java.time.Instant;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;

/**
 * Created by Administrator on 2017/4/16.
 */
public class AppV2 {
    private static final Logger logger = LoggerFactory.getLogger(AppV2.class);

    public static void main(String[] args) {
        // 添加JVM参数以解决Java代理动态加载警告
        // 这些警告来自360安全卫士的Java代理(com.baize.aegis.plugin.dependency.DependencyExtension)
        // 1. 启用代理使用跟踪
        System.setProperty("jdk.instrument.traceUsage", "true");
        // 2. 明确允许动态加载Java代理
        System.setProperty("jdk.instrument.allowNativeAccess", "true");
        // 3. 设置允许动态加载代理
        System.setProperty("jdk.enableDynamicAgentLoading", "true");
        
        SpringApp.application = new SpringApplication(SpringApp.class);

        BufferingApplicationStartup startup = new BufferingApplicationStartup(2000);
        SpringApp.application.setApplicationStartup(startup);
        if (logger.isDebugEnabled()) {
            logger.debug("应用程序启动参数:{}", (Object[]) args);
        }

        startup.start("");
        SpringApp.context = SpringApp.application.run(args);

        Duration between = Duration.between(startup.getBufferedTimeline().getStartTime(), Instant.now());
        if (logger.isDebugEnabled()) {
            logger.debug("application.run() cost:{}", between);
        }
    }

    public static final String DEFAULT_DB_HOST = "10.84.209.154"; // "db-server1.ecctrl.com"
    public static final String DEFAULT_DB_PORT = "3306";
    public static final String DEFAULT_DB_USERNAME = "supplier_ms";
    public static final String DEFAULT_DB_PASSWORD = "[TPdseO!JKMmlrpf";
    public static final String DEFAULT_DB_DATABASE = "supplier_ms";
}
