more debuglevel code cleanup

This commit is contained in:
Christopher Ramey 2021-02-28 04:51:35 -09:00
parent fcdff1039f
commit 5c50f4ac95
2 changed files with 4 additions and 6 deletions

View File

@ -118,7 +118,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
srv := server.NewServer(cfg, *debuglvl) srv := server.NewServer(cfg)
r, err := srv.Start() r, err := srv.Start()
if err != nil { if err != nil {

View File

@ -13,7 +13,6 @@ type Server struct {
workers []*worker workers []*worker
cfg *config.Config cfg *config.Config
shutdownc chan bool shutdownc chan bool
debuglvl int
http http.Server http http.Server
} }
@ -35,7 +34,7 @@ func (srv *Server) Start() (bool, error) {
for { for {
select { select {
case r := <-t.C: case r := <-t.C:
if srv.debuglvl > 0 { if srv.cfg.DebugLevel > 0 {
fmt.Printf("interval check at %s\n", r) fmt.Printf("interval check at %s\n", r)
} }
for _, w := range srv.workers { for _, w := range srv.workers {
@ -51,15 +50,14 @@ func (srv *Server) Start() (bool, error) {
} }
} }
func NewServer(cfg *config.Config, debuglvl int) *Server { func NewServer(cfg *config.Config) *Server {
srv := &Server{ srv := &Server{
cfg: cfg, cfg: cfg,
debuglvl: debuglvl,
shutdownc: make(chan bool, 1), shutdownc: make(chan bool, 1),
} }
for _, g := range cfg.Groups { for _, g := range cfg.Groups {
srv.workers = append( srv.workers = append(
srv.workers, makeworker(g, debuglvl), srv.workers, makeworker(g, cfg.DebugLevel),
) )
} }
return srv return srv