Skip to content

Commit

Permalink
Move lock file from /tmp to /var/run/lock. Do not run logrotate immed…
Browse files Browse the repository at this point in the history
…iately on boot. (#3250)

* Run logrotate after expected timeout to ensure systemd finishes its initial work and system is up. Move lock file from /tmp to /var/run/lock.
  • Loading branch information
vburenin authored Nov 21, 2016
1 parent bfbe571 commit 3fab0b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/filelock/flock.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type FileLock struct {
func NewFileLock(lockName string) *FileLock {
return &FileLock{
LockName: lockName,
LockFile: filepath.Join(os.TempDir(), lockName),
LockFile: filepath.Join("/var/run/lock", lockName),
}
}

Expand Down Expand Up @@ -65,6 +65,7 @@ func (fl *FileLock) Release() error {
if fl.fh == nil {
panic("Attempt to release not acquired lock!")
}
syscall.Flock(int(fl.fh.Fd()), syscall.LOCK_UN)
err := fl.fh.Close()
fl.fh = nil
fl.mu.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions pkg/logmgr/logmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ func (lm *LogManager) Start() error {
for {
lm.loopsCount++
if lm.loopsCount%10 == 0 {
lm.op.Debugf("logrotate has been run %s times")
lm.op.Debugf("logrotate has been run %d times", lm.loopsCount)
}
lm.rotateLogs()
select {
case <-time.After(lm.runInterval):
case <-lm.closed:
lm.rotateLogs()
lm.wg.Done()
return
}
lm.rotateLogs()
}
}()
})
Expand Down

0 comments on commit 3fab0b0

Please sign in to comment.