Exemplo n.º 1
0
func (this *ConfigController) Reload() {
	jsonResult := make(map[string]interface{})

	if strings.HasPrefix(this.Ctx.Request.RemoteAddr, "127.0.0.1") {
		err := g.ParseConfig(g.ConfigFile)

		if nil == err {
			this.Data["json"] = g.Config()
		} else {
			jsonResult["message"] = err.Error()
			this.Data["json"] = &jsonResult
		}
		this.ServeJSON()
	} else {
		this.Ctx.WriteString("no privilege")
	}
}
Exemplo n.º 2
0
func main() {
	cfg := flag.String("c", "cfg.json", "configuration file")
	version := flag.Bool("v", false, "show version")
	flag.Parse()

	if *version {
		fmt.Println(g.VERSION)
		os.Exit(0)
	}

	if err := g.ParseConfig(*cfg); err != nil {
		log.Fatalln(err)
	}
	logger.SetLevelWithDefault(g.Config().LogLevel, "info")

	models.Init()
	db.Init()

	go store.RefreshDesiredAgent()
	go store.CleanStaleHost()

	addr := g.Config().Listen.Addr
	if "" == addr {
		addr = "127.0.0.1"
	}

	if 0 >= g.Config().Listen.Port {
		return
	}

	beego.BConfig.CopyRequestBody = true
	beego.BConfig.WebConfig.Session.SessionOn = true
	beego.BConfig.Listen.HTTPAddr = addr
	beego.BConfig.Listen.HTTPPort = g.Config().Listen.Port

	http.Start()
}