func main() { cfg := flag.String("c", "cfg.json", "configuration file") version := flag.Bool("v", false, "show version") help := flag.Bool("h", false, "help") flag.Parse() if *version { fmt.Println(g.VERSION) os.Exit(0) } if *help { flag.Usage() os.Exit(0) } g.ParseConfig(*cfg) g.InitRedisConnPool() go http.Start() go cron.ReadHighEvent() go cron.ReadLowEvent() sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) go func() { <-sigs fmt.Println() g.RedisConnPool.Close() os.Exit(0) }() select {} }
func (this *MainController) ConfigReload() { remoteAddr := this.Ctx.Input.Request.RemoteAddr if strings.HasPrefix(remoteAddr, "127.0.0.1") { g.ParseConfig(g.ConfigFile) this.Data["json"] = g.Config() this.ServeJson() } else { this.Ctx.WriteString("no privilege") } }