-
-
Notifications
You must be signed in to change notification settings - Fork 134
Lazy Restart #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Lazy Restart #756
Changes from 12 commits
da2b5df
0ccb2cc
34cdc03
aca14f6
2fbdbbc
8d899a3
a0c60f9
f4ddbaf
3868589
85bca27
ceea334
60e0f8a
2d1154a
c13c2a3
a75df68
081a8a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,13 @@ | |
| "github.com/offen/docker-volume-backup/internal/errwrap" | ||
| ) | ||
|
|
||
| const LOCK_FILE = "/var/lock/dockervolumebackup.lock" | ||
|
|
||
| // lock opens a lockfile at the given location, keeping it locked until the | ||
| // caller invokes the returned release func. In case the lock is currently blocked | ||
| // by another execution, it will repeatedly retry until the lock is available | ||
| // or the given timeout is exceeded. | ||
| func (s *script) lock(lockfile string) (func() error, error) { | ||
| func (s *script) lock() (func() error, error) { | ||
| start := time.Now() | ||
| defer func() { | ||
| s.stats.LockedTime = time.Since(start) | ||
|
|
@@ -26,7 +28,8 @@ | |
| deadline := time.NewTimer(s.c.LockTimeout) | ||
| defer deadline.Stop() | ||
|
|
||
| fileLock := flock.New(lockfile) | ||
| fileLock := flock.New(LOCK_FILE) | ||
| defer s.removeWaitingFile() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused by the usage of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| for { | ||
| acquired, err := fileLock.TryLock() | ||
|
|
@@ -41,6 +44,7 @@ | |
| } | ||
|
|
||
| if !s.encounteredLock { | ||
| s.writeWaitingFile() | ||
| s.logger.Info( | ||
| fmt.Sprintf( | ||
| "Exclusive lock was not available on first attempt. Will retry until it becomes available or the timeout of %s is exceeded.", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.