Skip to content

Commit e916924

Browse files
authored
Merge pull request #21 from Civil/pid_file
Add an option to optionally create a pidfile
2 parents 63eeb7c + b385dca commit e916924

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

main.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/dgryski/go-expirecache"
2626
"github.com/dgryski/httputil"
2727
"github.com/facebookgo/grace/gracehttp"
28+
"github.com/facebookgo/pidfile"
2829
pickle "github.com/kisielk/og-rek"
2930
"github.com/peterbourgon/g2g"
3031
)
@@ -655,6 +656,7 @@ func main() {
655656
logtostdout := flag.Bool("stdout", false, "write logging output also to stdout")
656657
logdir := flag.String("logdir", "/var/log/carbonzipper/", "logging directory")
657658
interval := flag.Duration("i", 0, "interval to report internal statistics to graphite")
659+
pidFile := flag.String("pid", "", "pidfile (default: empty, don't create pidfile)")
658660

659661
flag.Parse()
660662

@@ -792,6 +794,14 @@ func main() {
792794

793795
go Config.pathCache.ec.ApproximateCleaner(10 * time.Second)
794796

797+
if *pidFile != "" {
798+
pidfile.SetPidfilePath(*pidFile)
799+
err = pidfile.Write()
800+
if err != nil {
801+
log.Fatalln("error during pidfile.Write():", err)
802+
}
803+
}
804+
795805
portStr := fmt.Sprintf(":%d", Config.Port)
796806
logger.Logln("listening on", portStr)
797807

0 commit comments

Comments
 (0)