runsvdir(8)

πŸ“¦
version 2.3.1 Β· 2 versions
, in alpine 3.24, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– runsvdir β€” from the System Manager's Manual bestie collection πŸ’–

okay so. imagine you have a whole folder of little service thingies and you need someone to babysit every single one of them, forever, and restart them the literal second they fall over. that someone? that's runsvdir. she's the group chat admin of your entire service directory and she never sleeps. 🫢


✨ NAME ✨

runsvdir β€” starts and monitors a collection of runsv(8) processes πŸ’…


🌸 SYNOPSIS 🌸

runsvdir [-P] dir [ log ]

πŸ¦‹ DESCRIPTION πŸ¦‹

so first things first: dir has to be a directory. like, non-negotiable, it's a directory. and log is a space holder for a readproctitle log, and it has to be at least seven characters long or just… not there at all. seven. count them. no cap. πŸ”’

runsvdir starts a runsv(8) process for every subdirectory β€” or symlink to a directory β€” inside the services directory dir, up to a limit of 1000 subdirectories. and if any of those runsv(8) processes terminates? she just starts it right back up. main character behavior honestly. ✨

she also skips subdirectory names that start with dots. invisible to her. ghosted. πŸ™ˆ

heads up bestie: runsv(8) must be in runsvdir's PATH. if it's not, this whole thing is not gonna go how you want it to. πŸ’€

At least every five seconds, runsvdir checks whether the time of last modification, the inode, or the device, of the services directory dir has changed. if it has, she re-scans the service directory. and then:

  • if she sees a new subdirectory, or a new symlink to a directory, in dir, she starts a new runsv(8) process πŸ”₯
  • if she sees a subdirectory being removed that was previously there, she sends the corresponding runsv(8) process a TERM signal, stops monitoring that process, and therefore does not restart the runsv(8) process if it exits πŸ‘‹

Now. If the log argument is given to runsvdir, all output to standard error gets redirected to this log, which is similar to the daemontools' readproctitle log. to see the most recent error messages, use a process-listing tool such as ps(1). and here's the cute part β€” runsvdir writes a dot to the readproctitle log every 15 minutes so that old error messages expire. a little period every quarter hour. she's cleaning up after herself. obsessed. πŸŽ€


πŸ’… OPTIONS πŸ’…

  • -P β€” use setsid(2) to run each runsv(8) process in a new session and separate process group. give them their own little rooms. their own vibe. 🌈

🌟 SIGNALS 🌟

  • If runsvdir receives a TERM signal, it exits with 0 immediately. she's out. gone. no drama. πŸ’¨
  • If runsvdir receives a HUP signal, it sends a TERM signal to each runsv(8) process it is monitoring and then exits with 111. group hug, everyone gets a TERM, then she leaves. 😭

πŸ‘‘ SEE ALSO πŸ‘‘

sv(8), runsv(8), runsvchdir(8), runit(8), runit-init(8), chpst(8), svlogd(8), utmpset(8), setsid(2)

https://smarden.org/runit/ πŸ”—


πŸ“ AUTHOR πŸ“

Gerrit Pape <pape@smarden.org> β€” thank you for the lore, king 🫢


and that's the whole page bestie!! this one lives in the System Manager's Manual, section runsvdir(8), and it's part of the runit universe over at https://smarden.org/runit/ β€” there's no date stamped on this version so like, consider it eternally fresh ✨ go restart something. slay. πŸ’–πŸ§š

πŸ“¦ where this page comes from