func (this *MainController) ConfigReload() { remoteAddr := this.Ctx.Input.Context.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") } }
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() model.InitDatabase() logger.InitLogger() go http.Start() go cron.ReadHighEvent() go cron.ReadLowEvent() go cron.CombineSms() go cron.CombineMail() go cron.CombineQQ() go cron.CombineServerchan() 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 {} }