Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Commit

Permalink
Implement pid file path in server tmp path (issue #14)
Browse files Browse the repository at this point in the history
Closes #14
  • Loading branch information
pcantera committed Dec 13, 2017
1 parent 47b9aba commit 807939e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmdpolling/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"syscall"
"time"
"encoding/json"
"strings"

log "github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
Expand Down Expand Up @@ -35,12 +36,17 @@ func handleSysSignals(cancelFunc context.CancelFunc) {
cancelFunc()
}

// Returns the full path to the tmp folder joined with pid management file name
func getProcessIdFilePath() string{
return strings.Join([]string{os.TempDir(), string(os.PathSeparator), ProcessIdFile}, "")
}

// Start the polling process
func cmdStart(c *cli.Context) error {
log.Debug("cmdStart")

formatter := format.GetFormatter()
if err := utils.SetProcessIdToFile(ProcessIdFile); err != nil {
if err := utils.SetProcessIdToFile(getProcessIdFilePath()); err != nil {
formatter.PrintFatal("cannot create the pid file", err)
}

Expand All @@ -65,7 +71,7 @@ func cmdStop(c *cli.Context) error {
log.Debug("cmdStop")

formatter := format.GetFormatter()
if err := utils.StopProcess(ProcessIdFile); err != nil {
if err := utils.StopProcess(getProcessIdFilePath()); err != nil {
formatter.PrintFatal("cannot stop the polling process", err)
}

Expand Down

0 comments on commit 807939e

Please sign in to comment.