use go-daemon library
This commit is contained in:
parent
8fd2cd77cf
commit
56fc88c9fc
1 changed files with 23 additions and 22 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue