channel close 버그 수정
This commit is contained in:
parent
8ebf91bf19
commit
560c93c2e4
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue