[BUGFIX] after database refactory
This commit is contained in:
parent
dcf1b6316c
commit
1464092a69
@ -21,10 +21,9 @@ type Config struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
configPath string
|
configPath string
|
||||||
collector *respond.Collector
|
collector *respond.Collector
|
||||||
connections database.Connection
|
nodes *runtime.Nodes
|
||||||
nodes *runtime.Nodes
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadConfig() *Config {
|
func loadConfig() *Config {
|
||||||
|
@ -29,7 +29,7 @@ var importCmd = &cobra.Command{
|
|||||||
log.Println("importing RRD from", path)
|
log.Println("importing RRD from", path)
|
||||||
|
|
||||||
for ds := range rrd.Read(path) {
|
for ds := range rrd.Read(path) {
|
||||||
connections.InsertGlobals(
|
allDatabase.Conn.InsertGlobals(
|
||||||
&runtime.GlobalStats{
|
&runtime.GlobalStats{
|
||||||
Nodes: uint32(ds.Nodes),
|
Nodes: uint32(ds.Nodes),
|
||||||
Clients: uint32(ds.Clients),
|
Clients: uint32(ds.Clients),
|
||||||
|
@ -54,7 +54,7 @@ var serveCmd = &cobra.Command{
|
|||||||
time.Sleep(delay)
|
time.Sleep(delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
collector = respond.NewCollector(connections, nodes, config.Respondd.Sites, config.Respondd.Interfaces, config.Respondd.Port)
|
collector = respond.NewCollector(allDatabase.Conn, nodes, config.Respondd.Sites, config.Respondd.Interfaces, config.Respondd.Port)
|
||||||
collector.Start(config.Respondd.CollectInterval.Duration)
|
collector.Start(config.Respondd.CollectInterval.Duration)
|
||||||
defer collector.Close()
|
defer collector.Close()
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,12 @@ import (
|
|||||||
"github.com/FreifunkBremen/yanic/database"
|
"github.com/FreifunkBremen/yanic/database"
|
||||||
)
|
)
|
||||||
|
|
||||||
var conn database.Connection
|
var Conn database.Connection
|
||||||
var wg = sync.WaitGroup{}
|
var wg = sync.WaitGroup{}
|
||||||
var quit chan struct{}
|
var quit chan struct{}
|
||||||
|
|
||||||
func Start(config database.Config) (err error) {
|
func Start(config database.Config) (err error) {
|
||||||
conn, err = Connect(config.Connection)
|
Conn, err = Connect(config.Connection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ func Start(config database.Config) (err error) {
|
|||||||
func Close() {
|
func Close() {
|
||||||
close(quit)
|
close(quit)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
conn.Close()
|
Conn.Close()
|
||||||
quit = nil
|
quit = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ func deleteWorker(deleteInterval time.Duration, deleteAfter time.Duration) {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
conn.PruneNodes(deleteAfter)
|
Conn.PruneNodes(deleteAfter)
|
||||||
case <-quit:
|
case <-quit:
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
|
Loading…
Reference in New Issue
Block a user