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.
Download it here:
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
--help option to get a full list of options.
Copyright (C) Daniel Beer 2015-2016 <>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.