- stats: use --workdir

This commit is contained in:
Simon Zolin
2019-09-06 15:42:21 +03:00
parent d0dcaeaa04
commit 97684368b9
4 changed files with 10 additions and 9 deletions

View File

@@ -62,7 +62,7 @@ type unitDB struct {
TimeAvg uint // usec
}
func createObject(filename string, limitDays int, unitID unitIDCallback) *statsCtx {
func createObject(filename string, limitDays int, unitID unitIDCallback) (*statsCtx, error) {
s := statsCtx{}
s.limit = limitDays * 24
s.filename = filename
@@ -72,7 +72,7 @@ func createObject(filename string, limitDays int, unitID unitIDCallback) *statsC
}
if !s.dbOpen() {
return nil
return nil, fmt.Errorf("open database")
}
id := s.unitID()
@@ -116,7 +116,7 @@ func createObject(filename string, limitDays int, unitID unitIDCallback) *statsC
go s.periodicFlush()
log.Debug("Stats: initialized")
return &s
return &s, nil
}
func (s *statsCtx) dbOpen() bool {