去掉常驻任务逻辑

写了再去掉……
This commit is contained in:
郝大全
2017-07-03 17:27:01 +08:00
parent 1300ca1a8b
commit 973e4b766f
9 changed files with 7 additions and 142 deletions

View File

@@ -16,9 +16,6 @@ import (
"strconv"
"strings"
"time"
"os/exec"
"log"
"os"
)
type TaskController struct {
@@ -46,9 +43,6 @@ func (this *TaskController) List() {
row["cron_spec"] = v.CronSpec
row["status"] = v.Status
row["description"] = v.Description
row["task_type"] = v.TaskType
e := jobs.GetEntryById(v.Id)
if e != nil {
row["next_time"] = beego.Date(e.Next, "Y-m-d H:i:s")
@@ -90,8 +84,6 @@ func (this *TaskController) Add() {
task.UserId = this.userId
task.GroupId, _ = this.GetInt("group_id")
task.TaskName = strings.TrimSpace(this.GetString("task_name"))
task.TaskTag = strings.TrimSpace(this.GetString("task_tag"))
task.TaskType, _ = this.GetInt("task_type")
task.Description = strings.TrimSpace(this.GetString("description"))
task.Concurrent, _ = this.GetInt("concurrent")
task.CronSpec = strings.TrimSpace(this.GetString("cron_spec"))
@@ -99,7 +91,6 @@ func (this *TaskController) Add() {
task.Notify, _ = this.GetInt("notify")
task.Timeout, _ = this.GetInt("timeout")
notifyEmail := strings.TrimSpace(this.GetString("notify_email"))
if notifyEmail != "" {
emailList := make([]string, 0)
@@ -146,8 +137,6 @@ func (this *TaskController) Edit() {
if this.isPost() {
task.TaskName = strings.TrimSpace(this.GetString("task_name"))
task.TaskTag = strings.TrimSpace(this.GetString("task_tag"))
task.TaskType, _ = this.GetInt("task_type")
task.Description = strings.TrimSpace(this.GetString("description"))
task.GroupId, _ = this.GetInt("group_id")
task.Concurrent, _ = this.GetInt("concurrent")
@@ -304,9 +293,6 @@ func (this *TaskController) Batch() {
if task, err := models.TaskGetById(id); err == nil {
task.Status = 0
task.Update()
if task.TaskType==1 {
stopProcess(task.TaskTag)//杀死进程
}
}
case "delete":
@@ -358,10 +344,6 @@ func (this *TaskController) Pause() {
task.Status = 0
task.Update()
//如果是常驻进程kill
if task.TaskType==1 {
stopProcess(task.TaskTag)
}
refer := this.Ctx.Request.Referer()
if refer == "" {
refer = beego.URLFor("TaskController.List")
@@ -385,11 +367,3 @@ func (this *TaskController) Run() {
job.Run()
this.redirect(beego.URLFor("TaskController.ViewLog", "id", job.GetLogId()))
}
//杀死进程
func stopProcess(taskTag string) {
ppPath,_ := os.Getwd() //项目根目录
shellFile := ppPath+"/kill_process.sh "
cmd:= exec.Command("sh","-c", shellFile + taskTag)
out,err:=cmd.Output()
log.Printf("==========================out:%s err:%s",out,err)
}