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