Rename nodes_dynamic_path to state_path
This commit is contained in:
parent
4cc93891ee
commit
5ca74e51bc
|
@ -13,8 +13,9 @@ webroot = "webroot"
|
|||
[nodes]
|
||||
enable = true
|
||||
nodes_version = 2
|
||||
nodes_path = "/var/www/html/meshviewer/data/nodes_all.json"
|
||||
nodes_path = "/var/www/html/meshviewer/data/nodes.json"
|
||||
graph_path = "/var/www/html/meshviewer/data/graph.json"
|
||||
state_path = "/var/lib/collector/state.json"
|
||||
|
||||
# Export nodes and graph periodically
|
||||
save_interval = "5s"
|
||||
|
|
|
@ -19,13 +19,13 @@ type Config struct {
|
|||
Webroot string
|
||||
}
|
||||
Nodes struct {
|
||||
Enable bool
|
||||
NodesVersion int
|
||||
NodesPath string
|
||||
NodesDynamicPath string
|
||||
GraphPath string
|
||||
SaveInterval Duration // Save nodes periodically
|
||||
PruneAfter Duration // Remove nodes after n days of inactivity
|
||||
Enable bool
|
||||
NodesVersion int
|
||||
NodesPath string
|
||||
GraphPath string
|
||||
StatePath string
|
||||
SaveInterval Duration // Save nodes periodically
|
||||
PruneAfter Duration // Remove nodes after n days of inactivity
|
||||
}
|
||||
Influxdb struct {
|
||||
Enable bool
|
||||
|
|
|
@ -18,6 +18,6 @@ func TestReadConfig(t *testing.T) {
|
|||
assert.Equal(time.Minute, config.Respondd.CollectInterval.Duration)
|
||||
|
||||
assert.Equal(2, config.Nodes.NodesVersion)
|
||||
assert.Equal("/var/www/html/meshviewer/data/nodes_all.json", config.Nodes.NodesPath)
|
||||
assert.Equal("/var/www/html/meshviewer/data/nodes.json", config.Nodes.NodesPath)
|
||||
assert.Equal(time.Hour*24*7, config.Nodes.PruneAfter.Duration)
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func NewNodes(config *Config) *Nodes {
|
|||
config: config,
|
||||
}
|
||||
|
||||
if config.Nodes.NodesDynamicPath != "" {
|
||||
if config.Nodes.StatePath != "" {
|
||||
nodes.load()
|
||||
}
|
||||
/**
|
||||
|
@ -178,7 +178,7 @@ func (nodes *Nodes) expire() {
|
|||
}
|
||||
|
||||
func (nodes *Nodes) load() {
|
||||
path := nodes.config.Nodes.NodesDynamicPath
|
||||
path := nodes.config.Nodes.StatePath
|
||||
|
||||
if f, err := os.Open(path); err == nil { // transform data to legacy meshviewer
|
||||
if err = json.NewDecoder(f).Decode(nodes); err == nil {
|
||||
|
@ -197,7 +197,7 @@ func (nodes *Nodes) save() {
|
|||
defer nodes.RUnlock()
|
||||
|
||||
// serialize nodes
|
||||
save(nodes, nodes.config.Nodes.NodesDynamicPath)
|
||||
save(nodes, nodes.config.Nodes.StatePath)
|
||||
|
||||
if path := nodes.config.Nodes.NodesPath; path != "" {
|
||||
version := nodes.config.Nodes.NodesVersion
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestLoadAndSave(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
config := &Config{}
|
||||
config.Nodes.NodesDynamicPath = "testdata/nodes.json"
|
||||
config.Nodes.StatePath = "testdata/nodes.json"
|
||||
|
||||
nodes := NewNodes(config)
|
||||
nodes.load()
|
||||
|
|
Loading…
Reference in New Issue