Commit c5119874 by 孙龙

up

parent 25566b89
......@@ -6,3 +6,4 @@
/master/main/master.json
/worker/main/worker.json
/.idea
/cmd
The file could not be displayed because it is too large.
The file could not be displayed because it is too large.
......@@ -5,6 +5,7 @@ go 1.12
require (
github.com/DataDog/zstd v1.4.4 // indirect
github.com/coreos/etcd v3.3.18+incompatible
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
......
SET CGO_ENABLED=0
SET GOOS=linux
SET GOARCH=amd64
SET CGO_ENABLED=0
SET GOOS=windows
SET GOARCH=amd64
......@@ -26,7 +26,7 @@ func (executor *Executor) ExecuteJob(info *common.JobExecuteInfo) {
err error
output []byte
result *common.JobExecuteResult
jobLock *JobLock
//jobLock *JobLock
)
......@@ -37,7 +37,7 @@ func (executor *Executor) ExecuteJob(info *common.JobExecuteInfo) {
}
// 初始化分布式锁
jobLock = G_jobMgr.CreateJobLock(info.Job.Name)
//jobLock = G_jobMgr.CreateJobLock(info.Job.Name)
// 记录任务开始时间
result.StartTime = time.Now()
......@@ -46,12 +46,13 @@ func (executor *Executor) ExecuteJob(info *common.JobExecuteInfo) {
// 随机睡眠(0~1s)
time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond)
err = jobLock.TryLock()
defer jobLock.Unlock()
if err != nil { // 上锁失败
result.Err = err
result.EndTime = time.Now()
} else {
//err = jobLock.TryLock()
//defer jobLock.Unlock()
//err = nil
//if err != nil { // 上锁失败
// result.Err = err
// result.EndTime = time.Now()
//} else {
// 上锁成功后,重置任务启动时间
result.StartTime = time.Now()
if ok :=strings.HasSuffix(info.Job.Command, ".sh");!ok{
......@@ -72,7 +73,7 @@ func (executor *Executor) ExecuteJob(info *common.JobExecuteInfo) {
}
}
//}
// 任务执行完成后,把执行的结果返回给Scheduler,Scheduler会从executingTable中删除掉执行记录
G_scheduler.PushJobResult(result)
}()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment