Skip to content

Commit

Permalink
If the contents of pidfile is same as own pid, don't raise error when…
Browse files Browse the repository at this point in the history
… creating pidfile.
  • Loading branch information
Songmu committed Mar 14, 2017
1 parent 814e88b commit 5ae9d79
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pidfile/pidfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func Create(pidfile string) error {
}
if pidString, err := ioutil.ReadFile(pidfile); err == nil {
if pid, err := strconv.Atoi(string(pidString)); err == nil {
if pid == os.Getpid() {
return nil
}
if ExistsPid(pid) {
return fmt.Errorf("pidfile found, try stopping another running mackerel-agent or delete %s", pidfile)
}
Expand Down

0 comments on commit 5ae9d79

Please sign in to comment.