Has anyone here written a deamon process in Golang? Can you walk me through how to do that? Useful links are welcome.
In a Unix environment, the parent process of a daemon is often, but not always, the init process. A daemon is usually created either by a process forking a child process and then immediately exiting, thus causing init to adopt the child process, or by the init process directly launching the daemon.
A daemon process is a background process that is not under the direct control of the user. This process is usually started when the system is bootstrapped and it terminated with the system shut down. Usually the parent process of the daemon process is the init process.
A daemon is a long-running background process that answers requests for services. The term originated with Unix, but most operating systems use daemons in some form or another. In Unix, the names of daemons conventionally end in "d". Some examples include inetd , httpd , nfsd , sshd , named , and lpd .
Yes this has been done. See the go-daemon project. Be aware that there are certain problems when the daemonization happens after goroutines are launched. See issue 227 for details.
At this time I'd recommend to use the utilities your operating system offers you. See this related question for solutions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With