package com.zd.gateway;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 网关启动程序
 *
 * @author zd
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class ZdGatewayApplication {
    static Logger logger = LoggerFactory.getLogger(ZdGatewayApplication.class);

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(ZdGatewayApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  云网关启动成功   ლ(´ڡ`ლ)ﾞ");

        Environment env = run.getEnvironment();
        try {
            logger.info("\n----------------------------------------------------------\n\t" +
                            "Application '{}' is running! Access URLs:\n\t" +
                            "Local: \t\thttp://localhost:{}\n\t" +
                            "External: \thttp://{}:{}\n\t" +
                            "文档地址: \thttp://{}:{}/doc.html\n\t" +
                            "----------------------------------------------------------",
                    env.getProperty("spring.application.name"),
                    env.getProperty("server.port"),
                    InetAddress.getLocalHost().getHostAddress(),
                    env.getProperty("server.port"),
                    InetAddress.getLocalHost().getHostAddress(),
                    env.getProperty("server.port")
            );
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

    }
}
