-
-
Notifications
You must be signed in to change notification settings - Fork 131
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 all commits
da2b5df
0ccb2cc
34cdc03
aca14f6
2fbdbbc
8d899a3
a0c60f9
f4ddbaf
3868589
85bca27
ceea334
60e0f8a
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 |
|---|---|---|
|
|
@@ -97,6 +97,7 @@ type Config struct { | |
| GoogleDriveImpersonateSubject string `split_words:"true"` | ||
| GoogleDriveEndpoint string `split_words:"true"` | ||
| GoogleDriveTokenURL string `split_words:"true"` | ||
| ActivateLazyRestart bool `split_words:"true" default:"false"` | ||
|
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 would think naming this |
||
| source string | ||
| additionalEnvVars map[string]string | ||
| } | ||
|
|
||
| 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 |
||
|
|
||
| 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.", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this should go in a dedicated PR. Thank you.