A lightweight daemonizer and process supervisor.
- Daemonize any process
- Process respawn with configurable conditions
- Custom working directory
- Run as a specific user/group
- Environment variable support
- Standard output/error redirection
- Graceful shutdown handling
- Configurable respawn delay and maximum respawn attempts
- C99 compatible compiler
- CMake 3.15.0 or higher
- POSIX compliant operating system
# Clone the repository
git clone https://github.com/cyberxnomad/rund.git
cd rund
# Create build directory
mkdir build
cd build
# Configure with CMake
cmake ..
# Build the project
make
# Install the program (optional, requires sudo)
sudo make installrund [options...] <target> [target_args...]| Short | Long | Description |
|---|---|---|
-o |
--stdout=FILE |
Redirect stdout to FILE (default: /dev/null) |
-e |
--stderr=FILE |
Redirect stderr to FILE (default: /dev/null) |
-c |
--chdir=DIR |
Change working directory to DIR |
-u |
--user=USER[:GROUP] |
Run target as USER and optionally GROUP |
-E |
--env=NAME=VALUE |
Set environment variable |
| Can be used multiple times | ||
-p |
--pidfile=FILE |
Write PID to FILE |
-r |
--respawn |
Enable auto-respawn on exit |
--respawn-code=CODE |
Respawn only if exit code equals CODE | |
| Can be used multiple times | ||
| Use -1 for any codes | ||
| Default: any non-zero codes (if -r is set) | ||
--respawn-delay=N |
Wait N seconds before respawning (default: 3) | |
--max-respawns=N |
Maximum respawn attempts (default: 0 = unlimited) | |
-h |
--help |
Display this help message and exit |
-V |
--version |
Show version information and exit |
-
Run a program as a daemon:
rund /path/to/your/program arg1 arg2
-
Redirect stdout and stderr to files:
rund -o /var/log/app.log -e /var/log/app.err /path/to/your/program
-
Set working directory and environment variables:
rund -c /app -E DEBUG=1 -E LOG_LEVEL=info /path/to/your/program
-
Enable respawning with custom conditions:
rund -r --respawn-code=1 --respawn-delay=5 --max-respawns=10 /path/to/your/program
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.