Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a daemon process in Golang? [duplicate]

Has anyone here written a deamon process in Golang? Can you walk me through how to do that? Useful links are welcome.

like image 909
Kasinath Kottukkal Avatar asked May 19 '14 10:05

Kasinath Kottukkal


People also ask

How is daemon process created?

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.

What is Daemonic process?

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.

What is a daemon in linux?

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 .


1 Answers

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.

like image 138
nemo Avatar answered Oct 17 '22 06:10

nemo