diff --git a/go-daemon/godaemon1.go b/go-daemon/godaemon1.go index 9e8ca87..9d3c5d1 100644 --- a/go-daemon/godaemon1.go +++ b/go-daemon/godaemon1.go @@ -1,33 +1,34 @@ package main import ( - // "log" + "log" "time" - // "github.com/sevlyar/go-daemon" + + "github.com/sevlyar/go-daemon" ) func main() { - // cntxt := &daemon.Context{ - // PidFileName: "godaemon1.pid", - // PidFilePerm: 0644, - // LogFileName: "godaemon1.log", - // LogFilePerm: 0640, - // WorkDir: "./", - // Umask: 027, - // Args: []string{"[go-daemon godaemon1]"}, - // } + cntxt := &daemon.Context{ + PidFileName: "godaemon1.pid", + PidFilePerm: 0644, + LogFileName: "godaemon1.log", + LogFilePerm: 0640, + WorkDir: "./", + Umask: 027, + Args: []string{"[go-daemon godaemon1]"}, + } - // d, err := cntxt.Reborn() - // if err != nil { - // log.Fatal("Unable to run: ", err) - // } - // if d != nil { - // return - // } - // defer cntxt.Release() - // - // log.Print("- - - - - - - - - - - - - - -") - // log.Print("daemon started") + d, err := cntxt.Reborn() + if err != nil { + log.Fatal("Unable to run: ", err) + } + if d != nil { + return + } + defer cntxt.Release() + + log.Print("- - - - - - - - - - - - - - -") + log.Print("daemon started") for true { Info()