This commit is contained in:
cdle
2021-10-17 14:46:52 +08:00
parent c415cf60ba
commit 796517bf4f
+5 -16
View File
@@ -2,6 +2,7 @@ package qinglong
import ( import (
"fmt" "fmt"
"strings"
"time" "time"
"github.com/cdle/sillyGirl/core" "github.com/cdle/sillyGirl/core"
@@ -22,19 +23,13 @@ func init() {
if err := Config.Req(CRONS, PUT, "/run", []byte(fmt.Sprintf(`["%s"]`, cron.Value))); err != nil { if err := Config.Req(CRONS, PUT, "/run", []byte(fmt.Sprintf(`["%s"]`, cron.Value))); err != nil {
return err return err
} }
i := 0
for { for {
i++ time.Sleep(time.Microsecond * 300)
time.Sleep(time.Second)
data, _ := GetCronLog(cron.Value) data, _ := GetCronLog(cron.Value)
if data != "" { if strings.Contains(data, "执行结束...") {
s.Reply(data) s.Reply(data)
break break
} }
if i > 5 {
s.Reply("执行异常。")
break
}
} }
if err := Config.Req(cron, CRONS, DELETE, []byte(`["`+cron.Value+`"]`)); err != nil { if err := Config.Req(cron, CRONS, DELETE, []byte(`["`+cron.Value+`"]`)); err != nil {
return err return err
@@ -55,19 +50,13 @@ func init() {
if err := Config.Req(CRONS, PUT, "/run", []byte(fmt.Sprintf(`["%s"]`, cron.Value))); err != nil { if err := Config.Req(CRONS, PUT, "/run", []byte(fmt.Sprintf(`["%s"]`, cron.Value))); err != nil {
return err return err
} }
i := 0
for { for {
i++ time.Sleep(time.Microsecond * 300)
time.Sleep(time.Second)
data, _ := GetCronLog(cron.Value) data, _ := GetCronLog(cron.Value)
if data != "" { if strings.Contains(data, "执行结束...") {
s.Reply(data) s.Reply(data)
break break
} }
if i > 5 {
s.Reply("执行异常。")
break
}
} }
if err := Config.Req(cron, CRONS, DELETE, []byte(`["`+cron.Value+`"]`)); err != nil { if err := Config.Req(cron, CRONS, DELETE, []byte(`["`+cron.Value+`"]`)); err != nil {
return err return err