Tag Archives | process supervisor

Daemon-ize your processes on the cheap!

Or, Death to /etc/rc.local!

TL;DR, or The Executive Summary: Init scripts are hard. Here’s a bunch of UNIX background backing up an argument for using stand-alone Process Supervisors whenever you need a new instance of a custom daemon spun up.

The setup

Picture. if you will, a pile of code.

Yeah, that’s good. The software equivalent of THAT mess.

If you write software, good odds that you’ve written at least one of these steaming sadness piles. If you work in operations, there’s better odds that you’ve been handed at least one failure-pile (this week). You or someone a lot like you needed a message consumer, some new hotness message bus, a stand-alone process that just listens for specific connections and commands on some random port or socket, or just some long-running process that runs non-interactively in the background (this being the very definition of daemon, by the way) and now this thing needs to run in production. In the wild. In the world at large, with other, nicer or bigger daemons grinding up page-to-page with it.

Invariably, the communication or documentation attached to this pig-pile of meadow-muffin-code almost always looks like this:

“Oh, just execute this and Bob’s Your Uncle, we’re all set! Just stick it in /etc/rc.local!”

    LD_LIBRARY_PATH=/some/crazy/nonstandard/path \
    /path/to/some/executable \
      OPTION OPTION OPTION OPTION OPTION >> /dev/null 2>&1 &
  
Say whaaaaaaaaaat?

Yeah… we’re not doing that. Why? For so, so many good reasons — redefining global variable scope, no PID tracking, no management, it gives me hives, because I said so, etc. ad infinitum.

Continue Reading →