From 0ed7ceff615fbaf839d8a3c8551ff8406dd0f5c5 Mon Sep 17 00:00:00 2001 From: wangyj Date: Wed, 17 Jan 2018 19:12:40 +0800 Subject: [PATCH] fix file fd leak --- fsm.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fsm.go b/fsm.go index 2346e8d..49d3206 100644 --- a/fsm.go +++ b/fsm.go @@ -194,7 +194,7 @@ func (p *Program) RunNotification(state FSMState) { ding := dingtalk.NewWebhook(group.Secret) err := ding.SendTextMsg(msg, false, group.Mobiles...) if err != nil { - log.Error("钉钉通知失败:", err) + log.Error("钉钉通知失败:", msg, err) } } } @@ -288,6 +288,9 @@ func (p *Process) buildCommand() *kexec.KCommand { } func (p *Process) waitNextRetry() { + if p.OutputFile != nil { + p.OutputFile.Close() + } p.SetState(RetryWait) if p.retryLeft <= 0 { p.retryLeft = p.StartRetries @@ -376,11 +379,13 @@ func (p *Process) startCommand() { return } } + p.waitNextRetry() case <-p.stopC: log.Println("recv stop command") p.stopCommand() // clean up all process } + }() }