mirror of https://github.com/shunfei/cronsun
bugfix:单机单进程模式下锁没正确释放
parent
26515e84c9
commit
8794fd12b9
6
job.go
6
job.go
|
@ -91,6 +91,7 @@ type locker struct {
|
|||
kind int
|
||||
ttl int64
|
||||
lID client.LeaseID
|
||||
lKey string
|
||||
timer *time.Timer
|
||||
done chan struct{}
|
||||
}
|
||||
|
@ -123,6 +124,10 @@ func (l *locker) unlock() {
|
|||
if _, err := DefalutClient.KeepAliveOnce(l.lID); err != nil {
|
||||
log.Warnf("unlock keep alive err: %s", err.Error())
|
||||
}
|
||||
err := DefalutClient.DelLock(l.lKey)
|
||||
if err != nil {
|
||||
log.Warnf("unlock[%s] err: %s", l.lKey, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
type Cmd struct {
|
||||
|
@ -265,6 +270,7 @@ func (c *Cmd) lock() *locker {
|
|||
}
|
||||
|
||||
lk.lID = resp.ID
|
||||
lk.lKey = c.Job.ID
|
||||
if lk.kind == KindAlone {
|
||||
go lk.keepAlive()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue