Table of Contents

Name

supervise - starts and monitors a service.

Synopsis

supervise s

Description

supervise switches to the directory named s and starts the service there by executing first ./start (if it is executable), and then ./run, if it exists. It restarts ./run if ./start exits zero or ./run exits with any value other than 100. It pauses for a second after starting ./run, so that it does not loop too quickly if ./run exits immediately. After ./run exits for the last time (ie after svc -d has been issued), it runs ./stop once.

Unless the file ./no-setsid exists, supervise will run subordinate processes in a new process group.

If ./log is an executable file, supervise starts it before any of the above, and will restart it if it exits. Standard output from the main script will be redirected through a pipe to standard input of the log process. As a special case, if svc -dx is issued, the log will be stopped after the main service has stopped.

If the file s/down exists, supervise does not start the service immediately. You can use svc(8) to start the service and to give other commands to supervise.

If the file s/notify exists and is executable, supervise executes it when any script starts or stops. It is given four command-line arguments: The first is the name of the script being executed, one of start, run, stop, or log. The second is a status code, one of:

start
The script started executing.
exit
The running script exited.
killed
The running script was killed by a signal.

The third is the process ID of the newly created or just exited process. The fourth is the exit code or kill signal number, or 0 on start.

supervise maintains status information in a binary format inside the directory s/supervise, which must be writable to supervise. The status information can be read by svstat(8) .

supervise may exit immediately after startup if it cannot find the files it needs in s or if another copy of supervise is already running in s. Once supervise is successfully running, it will not exit unless it is killed or specifically asked to exit. You can use svok(8) to check whether supervise is successfully running and svup(8) to check if the supervised process is running. You can use svscan(8) to reliably start a collection of supervise processes.

Environment

SUPERVISEDIR
If set, the named directory is used instead of supervise for the status information and control files. If $SUPERVISEDIR is an absolute path, it is suffixed with the path to s with all slashes ("/") replaced with colons (":").

See Also

envdir(8) , envini(8) , envuidgid(8) , fghack(8) , multilog(8) , pgrphack(8) , readproctitle(8) , setlock(8) , setuidgid(8) , softlimit(8) , svc(8) , svok(8) , svscan(8) , svscanboot(8) , svstat(8) , svup(8) , tai64n(8) , tai64nlocal(8)


Table of Contents