Example #1
0
func checkNodeValidity() {
	nodes, err := models.GetAllNode(nil)
	if err != nil {
		log.Panicf("failed to check node validity: %s" + err.Error())
	}

	for _, node := range nodes {
		if conf.IsMasterNode() {
			// only one master in cluster
			if node.Type == models.NODE_TYPE_MASTER && node.URL != conf.ClientAddr {
				if err := models.DeleteDBModel(nil, node); err != nil {
					log.Panicf("failed to check node validity: %s" + err.Error())
				}
				break
			}
		}
	}
}
Example #2
0
func loadAllData() {
	users, err := models.GetAllUser(nil)
	if err != nil {
		log.Panicf("Failed to load user info: %s", err.Error())
	}

	apps, err := models.GetAllApps(nil)
	if err != nil {
		log.Panicf("Failed to load app info: %s", err.Error())
	}

	webHooks, err := models.GetAllWebHooks(nil)
	if err != nil {
		log.Panicf("Failed to load webHook info: %s", err.Error())
	}

	configs, err := models.GetAllConfig(nil)
	if err != nil {
		log.Panicf("Failed to load config info: %s", err.Error())
	}

	nodes, err := models.GetAllNode(nil)
	if err != nil {
		log.Panicf("Failed to load node info: %s", err.Error())
	}

	dataVersion, err := models.GetDataVersion(nil)
	if err != nil {
		log.Panicf("Failed to load data version info: %s", err.Error())
	}

	clientParams, err := models.GetAllClientRequestData(nil)
	if err != nil {
		log.Panicf("Failed to load client request info: %s", err.Error())
	}

	fillMemConfData(users, apps, webHooks, configs, nodes, dataVersion)
	fillMemClientRequestData(clientParams)
}