daemon-manager

Allow non-root users to start and stop their own daemons

The current version is 0.98: Download (47K)

The development repository can found at github. You can get it like this:


   git clone git://github.com/caldwell/daemon-manager.git

Daemon Manager

Daemon Manager allows non-root users to start and stop their own daemons. It is perfect for running FastCGI servers, torrent servers, or any other daemon that isn’t meant to run in the root context.

Simplicity

Daemon Manager make it easy to set up new daemons. Here’s an example config file for a Minecraft server:

dir=/home/someone/minecraft
start=exec java -Xmx256M -Xms256M -jar minecraft_server.jar nogui

Availability

Daemon Manager will monitor processes and restart a daemon if it exits or crashes.

Security

Daemon Manager allows the system administrator to decide which users can launch daemons and what users they are allowed to launch daemons as. For instance, it is common to launch FastCGI servers as a different user ("www-data" on Debian or Ubuntu, "apache" on Fedora).

Users are only allowed to see and control daemons which they have been given access to by the system administrator.

Similarities

There are many other programs out there that manage daemons. Daemon Manager has many similarities with upstart, systemd, supervise (daemon-tools), and System V init scripts but it has a different feature set and is not designed to replace any of those. Here are some similarities and differences:

  • Like upstart, systemd and supervise, Daemon Manager will respawn a daemon that exits prematurely.

  • Like standard system V init scripts, there are no dependencies.

  • Users can be given control of their own daemons. These daemons may run as the user or as any other user on the system (if the system administrator gives them permission).

  • Special users can be given control over other users daemons (think help desk operators at a hosting company).

  • Configuration is very simple. Daemon config files are generally 4 lines or fewer in length.

Rationale

Daemon Manager was originally conceived as a way to keep track of the myriad FastCGI servers on machines that host a number of heterogeneous web sites using servers like Lighttpd and Nginx. It became obvious as work progressed that the program wouldn’t be specific to just FastCGI daemons, but that there were many use cases for daemons that a user might want to run as themselves (or another non-privileged user) and control themselves.

Building and testing from Git

You need a C++11 compiler installed to build.

make

That should build the daemon-manager and dmctl binaries.

If you want to build the man pages you’ll need AsciiDoc installed. On a Debian or Ubuntu system shhould be as easy as:

sudo apt install asciidoc

On macOS, get Homebrew and then:

brew install asciidoc

Once it is installed you can build with:

make man

If you’re testing locally you’ll want to build like this:

make COMMAND_SOCKET_PATH=./test.socket

Otherwise it will use the default global location for the socket (/var/run/daemon-manager.socket).

It’s also recommended to create a test config file and set the paths like:

[settings]
daemon-path-daemon      = ./test-daemons/%username%/daemons
daemon-path-log         = ./test-daemons/%username%/logs
daemon-path-daemon-root = ./test-daemons/root/daemons
daemon-path-log-root    = ./test-daemons/root/log

That way the local tests will be cordoned off.

Note
daemon-manager normally expects to run as root. A lot of code paths break when it is not run as root (e.g. daemons won’t launch because setuid fails). Even the test file needs to be root owned or the permissions check will fail and it will fail to launch.

Copyright © 2010-2023 by David Caldwell <david@porkrind.org>

Daemon Manager is licensed under the GNU General Public License (v3.0). See the LICENSE file for details.

Documentation

Last Modified on: Mar 25, 2023 12:41pm