diff --git a/bootstrap.go b/bootstrap.go index 1df54a9..b9fd036 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -29,6 +29,10 @@ func initLogger() func() { // 로깅설정 formatter := zapcore.NewConsoleEncoder(zlog.LogCommonFormat) + level := zap.InfoLevel + if *verbose{ + level=zap.DebugLevel + } // 전역 로거 초기화 var err error logger, err = zlog.Init( @@ -38,7 +42,7 @@ func initLogger() func() { "Stderr", "", nil, - zap.DebugLevel, + level, ) if err != nil { diff --git a/consumer/speed_controller.go b/consumer/speed_controller.go index 4985863..9d64c80 100644 --- a/consumer/speed_controller.go +++ b/consumer/speed_controller.go @@ -9,6 +9,7 @@ import ( "amuz.es/src/infra/goutils/handler" "amuz.es/src/infra/cpu_ctrl/producer" "go.uber.org/zap" + "github.com/alecthomas/chroma/lexers/m" ) var () @@ -45,12 +46,18 @@ func (c *fanControl) StartControl() { c.handler.NotifyError(err.(error)) } }() - defer close(c.fanSpeedConsumer) defer c.logger.Info("Fan control stopped") c.logger.Info("Fan control started") ticker := time.Tick(c.sampleDuration) pastFanSpeedList, newFanSpeedList := make([]int, c.processorCount), make([]int, c.processorCount) + + go func() { + for changedFanspeed := range c.fanSpeedConsumer { + newFanSpeedList[changedFanspeed.Id] = changedFanspeed.FanSpeed + } + }() + for { select { case <-ticker: @@ -58,8 +65,6 @@ func (c *fanControl) StartControl() { copy(pastFanSpeedList, newFanSpeedList) go c.applyFanspeed(pastFanSpeedList) } - case changedSpeed := <-c.fanSpeedConsumer: - newFanSpeedList[changedSpeed.Id] = changedSpeed.FanSpeed case <-c.handler.Done(): return }