daemon
daemon copied to clipboard
Invalid daemon kind specified
func main() { srv, err := daemon.New(name, description, daemon.SystemDaemon) if err != nil { // <-- Invalid daemon kind specified errlog.Println("Error: ************************", err) os.Exit(1) }
service := &Service{srv}
status, err := service.Manage()
if err != nil {
log.Fatal(status, "\nError: ", err)
}
fmt.Println(status)
rand.Seed(time.Now().UnixNano())
}
If you're running on MacOSX; the simple example will not work as daemon.SystemDaemon
is not supported. Try changing it to a different kind like GlobalDaemon
https://github.com/takama/daemon/blob/496d69192531c6cb1004380a0be0fcf2031b06f4/daemon.go#L211-L232
Tank you
Just trying out your package. The "problem" on macOS is that neither UserAgent
nor GlobalDaemon
really "daemonize" the process. Is this a bug?
Just trying out your package. The "problem" on macOS is that neither
UserAgent
norGlobalDaemon
really "daemonize" the process. Is this a bug?
Below code work for me for both MacOS and Linux.
func main() {
var kind daemon.Kind
switch runtime.GOOS {
case "darwin":
kind = daemon.GlobalDaemon
default:
kind = daemon.SystemDaemon
}
srv, err := daemon.New(name, description, kind, dependencies...)
if err != nil {
errlog.Println("Error: ", err)
os.Exit(1)
}
service := &Service{srv}
status, err := service.Manage()
if err != nil {
errlog.Println(status, "\nError: ", err)
os.Exit(1)
}
fmt.Println(status)
}