added batch restart tasks

This commit is contained in:
marvzhang
2020-07-18 11:33:07 +08:00
parent af420972ed
commit b1c5ffc540
5 changed files with 72 additions and 20 deletions

View File

@@ -39,7 +39,7 @@ task:
workers: 16
other:
tmppath: "/tmp"
version: 0.4.10
version: 0.5.0
setting:
crawlabLogToES: "N" # Send crawlab runtime log to ES, open this option "Y", remember to set esClient
crawlabLogIndex: "crawlab-log"

View File

@@ -252,6 +252,7 @@ func main() {
authGroup.GET("/tasks/:id/results/download", routes.DownloadTaskResultsCsv) // 下载任务结果
authGroup.POST("/tasks/:id/restart", routes.RestartTask) // 重新开始任务
authGroup.POST("/tasks-cancel", routes.CancelSelectedTask) // 批量取消任务
authGroup.POST("/tasks-restart", routes.RestartSelectedTask) // 批量重试任务
}
// 定时任务
{

View File

@@ -380,6 +380,22 @@ func CancelSelectedTask(c *gin.Context) {
HandleSuccess(c)
}
func RestartSelectedTask(c *gin.Context) {
ids := make(map[string][]string)
if err := c.ShouldBindJSON(&ids); err != nil {
HandleError(http.StatusBadRequest, c, err)
return
}
list := ids["ids"]
for _, id := range list {
if err := services.RestartTask(id, services.GetCurrentUserId(c)); err != nil {
HandleError(http.StatusInternalServerError, c, err)
return
}
}
HandleSuccess(c)
}
// @Summary Get task log
// @Description Get task log
// @Tags task