Exemple #1
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	if len(*configFile) == 0 {
		log.SysLog.Fatal("must use a config file")
		return
	}

	cfg, err := config.ParseConfigFile(*configFile)
	if err != nil {
		log.SysLog.Fatal(err.Error())
		return
	}

	//log.Init(&log.Config{FilePath: cfg.LogFile, LogLevel: *logLevel},
	//	&Config{FilePath: *logFile, LogLevel: *logLevel})

	// ***** Init the log from the config file ****** //
	//Default all the SysLog and AppLog are direct to the Same log File;
	log.Init(&log.Config{FilePath: *logFile, LogLevel: 0},
		&log.Config{FilePath: *logFile, LogLevel: log.GetLogLevelFromString(cfg.LogLevel)})

	var svr *proxy.Server
	svr, err = proxy.NewServer(cfg)
	if err != nil {
		log.SysLog.Fatal(err.Error())
		return
	}

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		http.ListenAndServe(":11888", nil)
	}()

	go func() {
		sig := <-sc
		log.SysLog.Notice("Got signal [%d] to exit.", sig)
		svr.Close()
	}()

	svr.Run()
}
Exemple #2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	if len(*configFile) == 0 {
		SysLog.Fatal("must use a config file")
		return
	}

	cfg, err := config.ParseConfigFile(*configFile)
	if err != nil {
		SysLog.Fatal(err.Error())
		return
	}

	//Init(&Config{FilePath: *logFile, LogLevel: *logLevel},
	//	&Config{FilePath: *logFile, LogLevel: *logLevel})

	var svr *proxy.Server
	svr, err = proxy.NewServer(cfg)
	if err != nil {
		SysLog.Fatal(err.Error())
		return
	}

	sc := make(chan os.Signal, 1)
	signal.Notify(sc,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		http.ListenAndServe(":11888", nil)
	}()

	go func() {
		sig := <-sc
		SysLog.Notice("Got signal [%d] to exit.", sig)
		svr.Close()
	}()

	svr.Run()
}