mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 19:57:42 +08:00
[FIX] Fix bugs that reset the configuration file every time
This commit is contained in:
parent
faef2dc77a
commit
dc3c2bed5d
@ -82,7 +82,7 @@ func NewManager(config *option.Config, a *AlertingRulesManager) *Manager {
|
||||
a: a,
|
||||
}
|
||||
m.LoadConfig()
|
||||
m.a.RulesConfig.SaveAlertingRulesConfig()
|
||||
m.a.RulesConfig.InitRulesConfig()
|
||||
|
||||
return m
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
)
|
||||
|
||||
type AlertingRulesConfig struct {
|
||||
@ -106,4 +107,17 @@ func (a *AlertingRulesConfig) AddRules(val AlertingNameConfig) error {
|
||||
group = append(group, &val)
|
||||
a.Groups = group
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AlertingRulesConfig) InitRulesConfig() {
|
||||
_, err := os.Stat("/etc/prometheus/rules.yml") //os.Stat获取文件信息
|
||||
if err != nil {
|
||||
if os.IsExist(err) {
|
||||
return
|
||||
}
|
||||
a.SaveAlertingRulesConfig()
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user