bugfix: server hearbeat
This commit is contained in:
parent
3963470603
commit
a38e50d6b8
|
@ -72,7 +72,7 @@ func AlertingEngineGetsInstances(where string, args ...interface{}) ([]string, e
|
|||
return arr, err
|
||||
}
|
||||
|
||||
func AlertingEngineHeartbeat(instance string) error {
|
||||
func AlertingEngineHeartbeat(instance, cluster string) error {
|
||||
var total int64
|
||||
err := DB().Model(new(AlertingEngines)).Where("instance=?", instance).Count(&total).Error
|
||||
if err != nil {
|
||||
|
@ -83,6 +83,7 @@ func AlertingEngineHeartbeat(instance string) error {
|
|||
// insert
|
||||
err = DB().Create(&AlertingEngines{
|
||||
Instance: instance,
|
||||
Cluster: cluster,
|
||||
Clock: time.Now().Unix(),
|
||||
}).Error
|
||||
} else {
|
||||
|
|
|
@ -74,6 +74,11 @@ func MustLoad(fpaths ...string) {
|
|||
C.ReaderFrom = "config"
|
||||
}
|
||||
|
||||
if C.ReaderFrom == "config" && C.ClusterName == "" {
|
||||
fmt.Println("configuration ClusterName is blank")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if C.Heartbeat.IP == "" {
|
||||
// auto detect
|
||||
// C.Heartbeat.IP = fmt.Sprint(GetOutboundIP())
|
||||
|
|
|
@ -37,7 +37,12 @@ func loopHeartbeat() {
|
|||
}
|
||||
|
||||
func heartbeat() error {
|
||||
err := models.AlertingEngineHeartbeat(config.C.Heartbeat.Endpoint)
|
||||
cluster := ""
|
||||
if config.C.ReaderFrom == "config" {
|
||||
cluster = config.C.ClusterName
|
||||
}
|
||||
|
||||
err := models.AlertingEngineHeartbeat(config.C.Heartbeat.Endpoint, cluster)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue