The s6-svstat program
s6-svstat prints a short, human-readable or programmatically parsable summary of the state of a process monitored by s6-supervise.
Interface
s6-svstat [ -uwNrpest | -o up,wantedup,normallyup,ready,paused,pid,pgid,exitcode,signal,signum,updownsince,readysince,updownfor,readyfor ] [ -n ] servicedir
s6-svstat gives information about the process being monitored at the servicedir service directory, then exits 0.
When s6-svstat is invoked without options, or with only the -n option, it prints a human-readable summary of all the available information on the service. In this case, the -n option instructs it to print a signal number (instead of a signal name) if the supervised process was killed by a signal. The summary includes the following data:
- whether the process is up or down, and if it's up, the number of seconds that it has been up.
- the process' pid, if it is up, or its last exit code or terminating signal, if it is down
- what its default state is, if it is different from its current state
- the number of seconds since it last changed states
- whether the service is ready, as notified by the daemon itself, and if it is, the number of seconds that it has been. A service reported as down and ready simply means that it is ready to be brought up. A service is down and not ready when it is in the cleanup phase, i.e. the ./finish script is still being executed.
When s6-svstat is invoked with one or several options other than -n, it outputs programmatically parsable information instead. The output is a series of space-separated values, one value per requested field. The valid options are as follows.
Options
- -o fields : list fields to print.
fields is a list of comma-separated field names. The valid field
names are the following:
- up: print true if the service is up and false if it is down.
- wantedup: print true if s6-supervise is currently instructed to (re)start the service when it is down, and false if s6-supervise is currently instructed to leave the service alone.
- normallyup: print true if the service is supposed to start when s6-supervise starts (i.e. no ./down file), and false if it is not (i.e. there is a ./down file).
- ready: print true if the service is ready, and false if it is not. Note that a service can be both down and ready: it simply means that it is ready to be started (i.e. no ./finish script is currently running). To check for service readiness, you should give this option along with up: the service is ready iff s6-svstat -o up,ready prints true true. (The true true case will never happen if the service does not support readiness notification.)
- paused: print true if the service is paused (i.e. the process is currently stopped) and false if it is not. It is a rare flag, you shouldn't normally need to use this option.
- pid: print the pid of the supervised process. If the service is currently down, -1 is printed instead.
- pgid: print the process group of the supervised process. If the service is currently down, print the process group of the last living instance of the service.
- exitcode: print the exit code of the last execution of ./run. If the service is currently up, or the last ./run process was killed by a signal, -1 is printed instead.
- signal: print the name of the signal the last ./run process was killed with. If the service is currently up, or the last ./run process was not killed by a signal, NA is printed instead.
- signum: print the number of the signal the last ./run process was killed with. If the service is currently up, or the last ./run process was not killed by a signal, -1 is printed instead.
- updownsince: print a TAI64N label representing the absolute date when the service last changed states.
- readysince: print a TAI64N label representing the absolute date when the service last became ready. Note that this can either mean "service readiness" (if the service is currently up and ready), or "down readiness", i.e. the last time when the service was down and ready to be started (if the service is not currently up and ready).
- updownfor: print the number of seconds that have elapsed since the service last changed states.
- readyfor: print the number of seconds that have elapsed since the service last became ready (or ready to be started if it's currently not up and ready).
- -u: equivalent to -o up.
- -w: equivalent to -o wantedup.
- -N: equivalent to -o normallyup.
- -r: equivalent to -o ready.
- -p: equivalent to -o pid.
- -g: equivalent to -o pgid.
- -e: equivalent to -o exitcode.
- -s: equivalent to -o signal.
- -t: equivalent to -o updownfor.
Exit codes
- 0: success
- 1: s6-supervise not running on servicedir
- 100: wrong usage
- 111: system call failed
Examples
- s6-svstat -o up,ready (or its equivalent s6-svstat -ur) will print true true if the service is up and ready, true false if the service has been started but has not notified readiness yet, false true if it is down and can be started, and false false if it is down and there's a ./finish script running that needs to exit before the service can be restarted.
- s6-svstat -o pid,exitcode,signal (or its equivalent s6-svstat -pes) will print 42 -1 NA if the service has been started and ./run's pid is 42; it will print -1 0 NA if the service is down and ./run last exited 0; it will print -1 -1 SIGTERM if the service is down and ./run was last killed by a SIGTERM - as can happen, for instance, when you down the service via a call to s6-svc -d.
