2
0
mirror of https://github.com/carlostrub/sisyphus synced 2024-11-13 13:10:40 +00:00
sisyphus/daemon.go
2017-03-14 20:27:05 +00:00

29 lines
456 B
Go

package main
import (
"os"
"strconv"
)
// See
// https://www.socketloop.com/tutorials/golang-daemonizing-a-simple-web-server-process-example
// for the process we are using to daemonize
// savePID stores a pidfile
func savePID(pidfile string, p int) error {
file, err := os.Create(pidfile)
if err != nil {
return err
}
defer file.Close()
_, err = file.WriteString(strconv.Itoa(p))
if err != nil {
return err
}
file.Sync()
return nil
}