Guides 11792 Published by

The guide explains how to install runit on Devuan as a lightweight alternative to systemd, starting with a quick apt-get command and then showing how to create service directories under /etc/sv. It walks you through writing a run script that keeps your process in the foreground, linking each directory into /var/service so runit can supervise it from boot onward. The article also offers practical troubleshooting advice—fixing permission problems, avoiding unit‑file confusion—and demonstrates how to set up multiple services like nginx, Docker, or MySQL with minimal effort. Finally, it notes runit's limitations for advanced socket activation or networking hooks and suggests considering other init systems when those features are required, but overall encourages keeping your Devuan box running smoothly without the bloat of systemd.



Using Runit on Devuan

If you’re running Devuan and want a minimal, reliable init replacement that doesn’t bring the whole systemd baggage, runit is your go‑to. You’ll learn how to get it installed, set up services, and keep them alive even when something goes wrong.

Step 1: Install Runit
sudo apt-get update && sudo apt-get install runit

Devuan’s package manager ships a clean, battle‑tested build of runit. It pulls in just the runtime and supervisor; no extra dependencies that could bloat your system.

Step 2: Prepare the Service Directory

Create a directory for your service under /etc/sv. For example, to keep nginx running:

sudo mkdir -p /etc/sv/nginx/run

Inside run, add an executable script that starts and restarts your program. A simple version for nginx looks like this:

#!/bin/sh
exec start-stop-daemon --start --quiet --background --pidfile /var/run/nginx.pid \
    --exec /usr/sbin/nginx -- -c /etc/nginx/nginx.conf

Make it executable:

sudo chmod +x /etc/sv/nginx/run

Runit expects a run script that stays in the foreground. The start-stop-daemon trick keeps nginx running as a background process while still allowing runit to monitor its PID.

Step 3: Enable the Service
sudo ln -s /etc/sv/nginx /var/service

That symlink tells runit to supervise /etc/sv/nginx. Runit watches /var/service for any linked directories and starts them automatically during boot.

Step 4: Test the Setup
sudo sv start nginx   # or just sv restart nginx

Check status:

sudo sv status nginx

You should see “alive” in green. If you kill the process, runit will immediately respawn it.

Common Pitfalls (and How I Learned Them)

I once tried to run a custom script that logged to /var/log/custom.log but forgot to make the log file writable by the service’s user. Runit kept restarting it in an endless loop, and my console filled with “permission denied” errors. The fix? Add --chuid to the start-stop-daemon command or simply give the directory proper permissions before starting.

Another hiccup: some people try to use systemd‑style unit files with runit. That never works because runit doesn’t read them. Stick to the simple run script, and you’re good.

Advanced: Using Runit for Multiple Services

If you have several services—say Docker, a MySQL instance, and a custom API—you can mirror the steps above for each:

sudo mkdir -p /etc/sv/docker/run
# add docker start script...
sudo ln -s /etc/sv/docker /var/service

sudo mkdir -p /etc/sv/mysql/run
# add mysql start script...
sudo ln -s /etc/sv/mysql /var/service

Runit will keep all of them alive, restart on crash, and report status in /var/log/runit. No need for a heavy process manager.

When Runit Might Not Be Enough

If you rely heavily on socket activation or want deep integration with network interfaces, runit’s simplicity can feel limiting. In those cases, consider OpenRC or s6, which offer more hooks. But for most everyday services—web servers, SSH, cron—runit is lean and rock‑solid.

Hope that helps you keep your Devuan box humming without the bloat of systemd.