# rund

Daniel Beer

1 Sep 2015

Rund is a lightweight stand-alone process supervisor for Linux. It takes an ordinary process and makes it into a supervised daemon, with automatic restart, rotating logs, and safe synchronized shutdown and startup. It doesn't require any installation, configuration files or special directory structures.

The implementation is a single C file of around 1,000 lines, with no dependencies outside of the standard C library. Compile it with:

gcc -O1 -Wall -o rund rund.c -lrt

Given a program which runs in the foreground, myprog, start it as a controllable daemon with:

./rund -l mylog -s mysock start myprog

You can run this command multiple times. Provided you always use the same control socket, only one supervisor/supervisee pair will start. If you kill myprog, or it otherwise crashes, it will restart after a short wait (this is configurable).

To shut down the daemon, use:

./rund -s mysock stop

This command performs a synchronous shutdown: it doesn't terminate until both the supervisee has exited and the supervisor has released all named resources. Doing a restart by running "stop" followed by "start" will yield correct race-free behaviour.

All output from the supervisee is logged and written to the given log file, along with other information from the supervisor. When the log reaches a certain size (by default 1 MB), it will be rotated, with up to a maximum of four files' worth of backlog.

You can test the status of the daemon with:

./rund -s mysock status     # Test to see if the supervisor is running
./rund -s mysock pstatus    # Test to see if the supervisee is running

Use the --help option to get a full list of options.