package com;
import com.haobang.config.SyslogConfig;
import com.kafka.kafkaProducer;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.netty.SyslogServer;
import  com.haobang.config.AppConfig;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import com.netty.SyslogServerBoth;


@MapperScan("com.common.mapper")
@SpringBootApplication
@EnableScheduling
public class SyslogServeMainApp {

    private static final Logger logger = LoggerFactory.getLogger(SyslogServeMainApp.class);

    public static void main(String[] args) {
        SpringApplication.run(SyslogServeMainApp.class, args);
        try {
            //System.out.println("syslogConfig TcpPort: "+  AppConfig.getSyslogTcpPort());
            int tcpPort = args.length > 0 ? Integer.parseInt(args[0]) : AppConfig.getSyslogTcpPort() ;
            int udpPort = args.length > 1 ? Integer.parseInt(args[1]) : AppConfig.getSyslogUdpPort();
            //SyslogServer server = new SyslogServer(tcpPort, udpPort);
            SyslogServerBoth server = new SyslogServerBoth(tcpPort, udpPort);
            logger.info("Application SyslogServer start !");
            server.start();

        }catch ( Exception ex)
        {
            System.out.println("Application Catch Error message: "+ex.getMessage());
            logger.error("Application Catch Error message: "+ex.getMessage());
        }
    }
}
