Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,17 @@ func runDaemon() error {
}

// saves daemon pid to pidfile.
if err := utils.NewPidfile(cfg.Pidfile); err != nil {
logrus.Errorf("failed to create pidfile: %s", err)
return err
}
defer func() {
if err := os.Remove(cfg.Pidfile); err != nil {
logrus.Errorf("failed to delete pidfile: %s", err)
if cfg.Pidfile != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Pidfile exists, do we need to truncate it's content ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at utils.NewPidfile, it won't go ahead when pidfile has value, it a common logic most process deal with.

if err := utils.NewPidfile(cfg.Pidfile); err != nil {
logrus.Errorf("failed to create pidfile: %s", err)
return err
}
}()
defer func() {
if err := os.Remove(cfg.Pidfile); err != nil {
logrus.Errorf("failed to delete pidfile: %s", err)
}
}()
}

// set pouchd oom-score
if err := utils.SetOOMScore(os.Getpid(), cfg.OOMScoreAdjust); err != nil {
Expand Down