Daemon Process in golang

Hi, Has anyone ever created a daemon process in go?

Generally speaking: don’t. Create a CLI program that runs in the foreground and prints log data to stdout. Then use a suitable service manager (systemd, launchd, SMF, daemon tools, runit, …) to run it in the background.


Thanks for the feedback, I was in doubt as I wanted to create a command line application that would stay in the background and could interact with it, I thought I could only solve it in go, I saw an approach https://github.com/takama/daemon but he Makes calls to the system …

The one exception to the above might be Windows services, which apparently need some sort of plumbing in the program to work right. Otherwise I think it’s misguided to attempt to handle daemonization yourself in 2017.

1 Like

Follow @calmh’s advice, programs should generally not daemonise themselves, that is the role of a process supervisor like systemd, upstart, daemontools, etc.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.