daemon icon indicating copy to clipboard operation
daemon copied to clipboard

Invalid daemon kind specified

Open ImanMousavi opened this issue 3 years ago • 4 comments

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())

}

ImanMousavi avatar Oct 25 '21 15:10 ImanMousavi

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

NateThornton avatar Feb 03 '22 15:02 NateThornton

Tank you

ImanMousavi avatar Mar 02 '22 20:03 ImanMousavi

Just trying out your package. The "problem" on macOS is that neither UserAgent nor GlobalDaemon really "daemonize" the process. Is this a bug?

prologic avatar Mar 21 '22 15:03 prologic

Just trying out your package. The "problem" on macOS is that neither UserAgent nor GlobalDaemon 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)
}

doothez avatar Dec 19 '22 00:12 doothez