mirror of https://github.com/shunfei/cronsun
Merge branch 'develop' of github.com:shunfei/cronsun into develop
commit
78d9e4e5e1
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
`cronsun` 是为了解决多台 `*nix` 机器上`crontab` 任务管理不方便的问题,同时提供任务高可用的支持(当某个节点死机的时候可以自动调度到正常的节点执行)。`cronsun` 和 [Azkaban](https://azkaban.github.io/)、[Chronos](https://mesos.github.io/chronos/)、[Airflow](https://airflow.incubator.apache.org/) 这些不是同一类型的。
|
`cronsun` 是为了解决多台 `*nix` 机器上`crontab` 任务管理不方便的问题,同时提供任务高可用的支持(当某个节点死机的时候可以自动调度到正常的节点执行)。`cronsun` 和 [Azkaban](https://azkaban.github.io/)、[Chronos](https://mesos.github.io/chronos/)、[Airflow](https://airflow.incubator.apache.org/) 这些不是同一类型的。
|
||||||
|
|
||||||
|
## 项目状态
|
||||||
|
|
||||||
|
`cronsun`已经在线上几百台规模的服务器上面稳定运行了一年多了,虽然目前版本不是正式版,但是我们认为是完全可以用于生产环境的。强烈建议你试用下,因为它非常简单易用,同时感受下他的强大,相信你会喜欢上这个工具的。
|
||||||
|
|
||||||
## 架构
|
## 架构
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
8
job.go
8
job.go
|
@ -167,15 +167,13 @@ func (j *Job) limit() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更精确的控制是加锁
|
count := atomic.AddInt64(j.Count, 1)
|
||||||
// 两次运行时间极为接近的任务才可能出现控制不精确的情况
|
if j.Parallels < count {
|
||||||
count := atomic.LoadInt64(j.Count)
|
atomic.AddInt64(j.Count, -1)
|
||||||
if j.Parallels <= count {
|
|
||||||
j.Fail(time.Now(), fmt.Sprintf("job[%s] running on[%s] running:[%d]", j.Key(), j.runOn, count))
|
j.Fail(time.Now(), fmt.Sprintf("job[%s] running on[%s] running:[%d]", j.Key(), j.runOn, count))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic.AddInt64(j.Count, 1)
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue