This commit is contained in:
cdle
2021-10-17 14:56:03 +08:00
parent 796517bf4f
commit 4484cdbe30
+27
View File
@@ -64,5 +64,32 @@ func init() {
return nil
},
},
{
Rules: []string{`repo ?`},
Admin: true,
Handle: func(s core.Sender) interface{} {
cron := &Carrier{
Get: "data._id",
}
if err := Config.Req(cron, CRONS, POST, []byte(`{"name":"sillyGirl临时创建任务","command":"task `+s.Get()+`","schedule":" 1 1 1 1 1"}`)); err != nil {
return err
}
if err := Config.Req(CRONS, PUT, "/run", []byte(fmt.Sprintf(`["%s"]`, cron.Value))); err != nil {
return err
}
for {
time.Sleep(time.Microsecond * 300)
data, _ := GetCronLog(cron.Value)
if strings.Contains(data, "执行结束...") {
s.Reply(data)
break
}
}
if err := Config.Req(cron, CRONS, DELETE, []byte(`["`+cron.Value+`"]`)); err != nil {
return err
}
return nil
},
},
})
}