Home > Godaemon, a Library to Daemonize Go Apps

Godaemon, a Library to Daemonize Go Apps

At SolarWinds® Database Performance Monitor we have a specific need to daemonize one of our Go applications, which must safely run detached from terminals, with a working directory that won’t hang a u-mount, and so forth. This is variously said to be a bad idea in general, impossible to do in Go, or dangerous to do in Go if you hack it in with unsafe syscalls to fork. So we didn’t do it like that. Instead, we made a library that cryptographically signs an environment variable, starts a copy of itself, and then exits. The copy of itself makes some environment modifications and starts another copy of itself, then exits. The final copy restores the original environment variable and then continues executing. The result is a program that has all the properties of a daemon, but arrives at them in a different way than people usually try to do. It should be used carefully and only if you understand how these things work, but we’ve been running it in production with absolutely no problems for many months on many systems. We hope this is helpful if you have a similar need!
Baron Schwartz
Baron is a performance and scalability expert who participates in various database, open-source, and distributed systems communities. He has helped build and scale many large,…
Read more

Tweets

SolarWinds's Twitter avatar
SolarWinds
@solarwinds

@AGarejo Hello, We are working towards releasing Orion 2020.2.4 and appreciate the patience of you and all our cust… t.co/x4lwFQFsU4

SolarWinds's Twitter avatar
SolarWinds
@solarwinds

@DrPayload Hello, Thanks for reaching out. Please send us a DM with your contact info and we'll have someone get in… t.co/CvxmQO6hxN

SolarWinds's Twitter avatar
SolarWinds
@solarwinds

As the role of the #ITPro continues to evolve, what are the top skills needed? Find out in this article. t.co/bDhW4DmaoR