[BUGFIX] after database refactory

This commit is contained in:
Martin Geno 2018-01-19 04:31:33 +01:00
parent dcf1b6316c
commit 1464092a69
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
4 changed files with 9 additions and 10 deletions

View File

@ -23,7 +23,6 @@ type Config struct {
var (
configPath string
collector *respond.Collector
connections database.Connection
nodes *runtime.Nodes
)

View File

@ -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),

View File

@ -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()
}

View File

@ -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()