-
Notifications
You must be signed in to change notification settings - Fork 34
/
taskLogs.go
73 lines (63 loc) · 1.59 KB
/
taskLogs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package apps
import (
"github.com/TeaWeb/code/teaconfigs/agents"
"github.com/TeaWeb/code/teadb"
"github.com/TeaWeb/code/teaweb/actions/default/agents/agentutils"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/logs"
"github.com/iwind/TeaGo/maps"
)
type TaskLogsAction actions.Action
// 任务日志
func (this *TaskLogsAction) Run(params struct {
AgentId string
AppId string
TaskId string
Tabbar string
}) {
this.Data["tabbar"] = params.Tabbar
agentutils.InitAppData(this, params.AgentId, params.AppId, params.Tabbar)
agent := agents.NewAgentConfigFromId(params.AgentId)
if agent == nil {
this.Fail("找不到Agent")
}
app := agent.FindApp(params.AppId)
if app == nil {
this.Fail("找不到App")
}
task := app.FindTask(params.TaskId)
if task == nil {
this.Fail("找不到要修改的任务")
}
this.Data["task"] = maps.Map{
"id": task.Id,
"name": task.Name,
"on": task.On,
"script": task.Script,
"cwd": task.Cwd,
"isBooting": task.IsBooting,
"isManual": task.IsManual,
"env": task.Env,
"schedules": lists.Map(task.Schedule, func(k int, v interface{}) interface{} {
s := v.(*agents.ScheduleConfig)
return maps.Map{
"summary": s.Summary(),
}
}),
}
this.Show()
}
// 日志数据
func (this *TaskLogsAction) RunPost(params struct {
AgentId string
TaskId string
LastId string
}) {
taskLogs, err := teadb.AgentLogDAO().FindLatestTaskLogs(params.AgentId, params.TaskId, params.LastId, 100)
if err != nil {
logs.Error(err)
}
this.Data["logs"] = taskLogs
this.Success()
}