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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
// "github.com/sevlyar/go-daemon"
|
|
||||||
|
"github.com/sevlyar/go-daemon"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// cntxt := &daemon.Context{
|
cntxt := &daemon.Context{
|
||||||
// PidFileName: "godaemon1.pid",
|
PidFileName: "godaemon1.pid",
|
||||||
// PidFilePerm: 0644,
|
PidFilePerm: 0644,
|
||||||
// LogFileName: "godaemon1.log",
|
LogFileName: "godaemon1.log",
|
||||||
// LogFilePerm: 0640,
|
LogFilePerm: 0640,
|
||||||
// WorkDir: "./",
|
WorkDir: "./",
|
||||||
// Umask: 027,
|
Umask: 027,
|
||||||
// Args: []string{"[go-daemon godaemon1]"},
|
Args: []string{"[go-daemon godaemon1]"},
|
||||||
// }
|
}
|
||||||
|
|
||||||
// d, err := cntxt.Reborn()
|
d, err := cntxt.Reborn()
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// log.Fatal("Unable to run: ", err)
|
log.Fatal("Unable to run: ", err)
|
||||||
// }
|
}
|
||||||
// if d != nil {
|
if d != nil {
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
// defer cntxt.Release()
|
defer cntxt.Release()
|
||||||
//
|
|
||||||
// log.Print("- - - - - - - - - - - - - - -")
|
log.Print("- - - - - - - - - - - - - - -")
|
||||||
// log.Print("daemon started")
|
log.Print("daemon started")
|
||||||
|
|
||||||
for true {
|
for true {
|
||||||
Info()
|
Info()
|
||||||
|
|
Loading…
Reference in a new issue