func (c *Context) ConfigReload(rw web.ResponseWriter, req *web.Request) { // if strings.HasPrefix(req.RemoteAddr, "127.0.0.1") { err := config.LoadConfig(config.ConfigFile) if err != nil { c.WriteResponse(map[string]string{"msg": err.Error()}) } else { // var buf bytes.Buffer // en := toml.NewEncoder(&buf) // err := en.Encode(config.AppConfig()) // if err != nil { // c.WriteResponse(map[string]string{"msg": err.Error()}) // } // fmt.Println(buf.String()) c.WriteResponse(config.AppConfig()) } // } else { // c.WriteResponse(map[string]string{"msg": "permission denied"}) // } }
func main() { flag.Parse() if *versionFlag { fmt.Println(VERSION) os.Exit(0) } if *logstashFlag { log.ChangeToLogstashFormater(APP_NAME) } log.SetLogFile(LOG_FILE) err := config.LoadConfig(*cfgFileFlag) if err != nil { log.Fatalln(err) } pid := os.Getpid() // Save the pid into the pid file. err = utils.WriteFile(PID_FILE, []byte(strconv.Itoa(pid)), 0644) if err != nil { log.Fatalln(err) } defer os.Remove(PID_FILE) go api.Start() // catch some signal sigCh := make(chan os.Signal) signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM, os.Kill) // Block until a signal is received. s := <-sigCh log.Debugf("Caught Signal: %s, shutting down...", s) }