s6
Software
skarnet.org
The s6-svc program
s6-svc sends commands to a running s6-supervise
process. In other words, it's used to control a supervised process; among
other benefits, it allows an administrator to send signals to daemons without
knowing their PIDs, and without using horrible hacks such as .pid files.
Interface
s6-svc [ -D | -U ] [ -T timeout ] [ -abqhkti12pcoduxO ] servicedir
s6-svc sends the given series of commands to the
s6-supervise process monitoring the
servicedir directory, then exits 0. It exits 111 if it cannot send
a command, or 100 if no s6-supervise process is running on servicedir.
Options
- -a : send a SIGALRM to the supervised process
- -b : send a SIGABRT to the supervised process
- -q : send a SIGQUIT to the supervised process
- -h : send a SIGHUP to the supervised process
- -k : send a SIGKILL to the supervised process
- -t : send a SIGTERM to the supervised process
- -i : send a SIGINT to the supervised process
- -1 : send a SIGUSR1 to the supervised process
- -2 : send a SIGUSR2 to the supervised process
- -p : send a SIGSTOP to the supervised process
- -c : send a SIGCONT to the supervised process
- -o : once. Equivalent to "-uO".
- -d : down. If the supervised process is up, send it
a SIGTERM and a SIGCONT. Do not restart it.
- -u : up. If the supervised process is down, start it.
Automatically restart it when it dies.
- -x : exit. When the service is asked to be down and
the supervised process dies, s6-supervise will exit too. This command should
normally never be used on a working system.
- -O : Once at most. Do not restart the supervised process
when it dies. If it is down when the command is received, do not even start
it.
- -T timeout : if the -D or
-U option has been given, -T specifies a timeout
(in milliseconds) after which s6-svc will exit 1 with an error message if
the service still hasn't reached the desired state. By default, the
timeout is 0, which means that s6-svc will block indefinitely.
- -D : s6-svc will not exit until the service is down.
- -U : s6-svc will not exit until the service is up and
ready as notified by the daemon itself.
Be careful to only use this command on services that send readiness
notifications and are managed by s6-notifywhenup,
else the command will never be successful.
Usage examples
s6-svc -h /service/httpd
Send a SIGHUP to the process represented by the /service/httpd
service directory. Traditionally, this makes web servers reload their
configuration file.
s6-svc -t /service/sshd
Kill (and automatically restart, if the wanted state of the service is up)
the process represented by the /service/sshd service directory -
typically the sshd server.
s6-svc -Dd /service/ftpd
Take down the ftpd server and block until the process is really down.
s6-svc -Uu -T 5000 /service/ftpd
Bring up the ftpd server and block until it has sent notification that it
is ready. Exit 1 if it is still not ready after 5 seconds.
s6-svc -a /service/httpd/log
Send a SIGALRM to the logger process for the httpd server. If this logger
process is s6-log, this triggers a log rotation.
Internals
- s6-svc writes control commands into the servicedir/supervise/control
FIFO. A s6-supervise process running on servicedir will be listening to this FIFO,
and will read and interpret those commands.
- When invoked with the -D or -U option, s6-svc executes into
s6-svlisten1, which will listen to service state
changes and spawn another s6-svc instance (without the -D or -U
option) that will send the commands to the service. Any error message written during
the waiting period will mention it is being written by s6-svlisten1; this is normal.