sv(8)

πŸ’… sv(8) β€” the manual, but make it make sense

okay so bestie, you're reading the System Manager's Manual page for sv, and honestly? it's a whole vibe. let me walk you through it 🫢

✨ NAME ✨

sv β€” control and manage services monitored by runsv(8) πŸ‘‘

πŸ¦‹ SYNOPSIS πŸ¦‹

sv [-v] [-w sec] command services

/etc/init.d/service [-w sec] command

🌸 DESCRIPTION 🌸

sv is literally the girl who reports the current status and controls the state of services monitored by the runsv(8) supervisor. main character energy, no cap ✨

services is one or more arguments, and each argument names a directory service used by runsv(8). so like, one or more, bestie, you can pass a bunch πŸ’…

here's the lookup rule and it's important so pay attention πŸ™ˆ β€” if service doesn't start with a dot or a slash and doesn't end with a slash, it gets searched in the default services directory /service/. otherwise it's resolved relative to the current directory.

command is one of up, down, status, once, pause, cont, hup, alarm, interrupt, 1, 2, term, kill, or exit, or start, stop, restart, shutdown, force-stop, force-reload, force-restart, force-shutdown. yes that's a lot, no i'm not sorry πŸ’€

sv can be sym-linked to /etc/init.d/ to provide an LSB init script interface. in that case, the service to be controlled is specified by the base name of the init script. iykyk 🧚


πŸŽ€ COMMANDS πŸŽ€

  • status β€” report the current status of the service to standard output, plus the appendant log service if there is one. it's giving "receipts" πŸ’–
  • up β€” if the service is not running, start it. if the service stops, restart it. ride or die behavior fr fr πŸ”₯
  • down β€” if the service is running, send it the TERM signal, and the CONT signal. if ./run exits, start ./finish if it exists. after it stops, do not restart the service. it's over, she's not coming back πŸ’€
  • once β€” if the service is not running, start it. do not restart it if it stops. one shot, one opportunity 🎯
  • pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill β€” if the service is running, send it the STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, or KILL signal respectively. pick your fighter 🌈
  • exit β€” if the service is running, send it the TERM signal, and the CONT signal. do not restart the service. ok and then it gets a little unhinged, stay with me:
    • if the service is down, and no log service exists, runsv(8) exits.
    • if the service is down and a log service exists, runsv(8) closes the standard input of the log service and waits for it to terminate.
    • if the log service is down, runsv(8) exits.
    • this command is ignored if it is given to an appendant log service. πŸ™ˆ
ngl this next line is the most important line on the whole page: sv actually looks only at the first character of these commands. so like, s is doing a LOT of heavy lifting here. be normal about it πŸ’…

⭐ Commands compatible to LSB init script actions

  • status β€” same as status. iconic, consistent, no notes πŸ‘‘
  • start β€” same as up, but wait up to 7 seconds for the command to take effect. then report the status or timeout. and listen: if the script ./check exists in the service directory, sv runs this script to check whether the service is up and available; it's considered to be available if ./check exits with 0. 🫢
  • stop β€” same as down, but wait up to 7 seconds for the service to become down. then report the status or timeout.
  • reload β€” same as hup, and additionally report the status afterwards. so extra of her ✨
  • restart β€” send the commands term, cont, and up to the service, and wait up to 7 seconds for the service to restart. then report the status or timeout. if the script ./check exists in the service directory, sv runs this script to check whether the service is up and available again; it's considered to be available if ./check exits with 0. πŸ”„
  • shutdown β€” same as exit, but wait up to 7 seconds for the runsv(8) process to terminate. then report the status or timeout.
  • force-stop β€” same as down, but wait up to 7 seconds for the service to become down. then report the status, and on timeout send the service the kill command. she asked nicely first πŸ’€
  • force-reload β€” send the service the term and cont commands, and wait up to 7 seconds for the service to restart. then report the status, and on timeout send the service the kill command.
  • force-restart β€” send the service the term, cont and up commands, and wait up to 7 seconds for the service to restart. then report the status, and on timeout send the service the kill command. if the script ./check exists in the service directory, sv runs this script to check whether the service is up and available again; it's considered to be available if ./check exits with 0. πŸ”₯
  • force-shutdown β€” same as exit, but wait up to 7 seconds for the runsv(8) process to terminate. then report the status, and on timeout send the service the kill command.
  • try-restart β€” if the service is running, send it the term and cont commands, and wait up to 7 seconds for the service to restart. then report the status or timeout. lowkey the most polite one here 🌸

🧚 Additional Commands

  • check β€” check for the service to be in the state that's been requested (up or down). wait up to 7 seconds for the service to reach the requested state, then report the status or timeout. if the requested state of the service is up, and the script ./check exists in the service directory, sv runs this script to check whether the service is up and running; it's considered to be up if ./check exits with 0. vibe check, literally βœ…

πŸ’œ OPTIONS πŸ’œ

  • -v β€” if the command is up, down, term, once, cont, or exit, then wait up to 7 seconds for the command to take effect. then report the status or timeout. patience is a virtue bestie πŸ•°οΈ
  • -w sec β€” override the default timeout of 7 seconds with sec seconds. this option implies -v. you're in charge now πŸ‘‘

🌈 ENVIRONMENT 🌈

  • SVDIR β€” the environment variable $SVDIR overrides the default services directory /service/. πŸ—‚οΈ
  • SVWAIT β€” the environment variable $SVWAIT overrides the default 7 seconds to wait for a command to take effect. it is overridden by the -w option. so -w beats $SVWAIT, noted πŸ“

πŸ“ EXIT CODES πŸ“

sv exits 0, if the command was successfully sent to all services, and, if it was told to wait, the command has taken effect to all services. slay πŸ’–

for each service that caused an error (e.g. the directory is not controlled by a runsv(8) process, or sv timed out while waiting), sv increases the exit code by one and exits non zero. the maximum is 99. sv exits 100 on error. 😭

and if sv is called with a base name other than sv, the rules change, so like, heads up:

  • it exits 1 on timeout or trouble sending the command
  • if the command is status, it exits 3 if the service is down, and 4 if the status is unknown
  • it exits 2 on wrong usage
  • and 151 on error πŸ’€

πŸ”₯ SEE ALSO πŸ”₯

runsv(8), chpst(8), svlogd(8), runsvdir(8), runsvchdir(8), runit(8), runit-init(8)

https://smarden.org/runit/


πŸ‘‘ AUTHOR πŸ‘‘

Gerrit Pape <pape@smarden.org>


and that's the whole page, bestie βœ¨πŸ’…πŸ¦‹ β€” this little masterpiece lives in the System Manager's Manual as sv(8), and the footer's just sv(8) again because the manual already knows her name πŸŽ€ go forth and manage those services, you absolute icon 🫢🌸

πŸ“¦ where this page comes from