diff options
Diffstat (limited to 'src/genrc.8')
-rw-r--r-- | src/genrc.8 | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/genrc.8 b/src/genrc.8 index 00522ee..959a00e 100644 --- a/src/genrc.8 +++ b/src/genrc.8 @@ -15,3 +15,3 @@ .\" along with genrc. If not, see <http://www.gnu.org/licenses/>. -.TH GENRC 8 "May 17, 2018" "GENRC" "Genrc User Manual" +.TH GENRC 8 "May 20, 2018" "GENRC" "Genrc User Manual" .SH NAME @@ -38,2 +38,4 @@ genrc \- generic system initialization script helper [\fB\-\-program=\fIPROGRAM\fR]\ + [\fB\-\-restart\-on\-exit=\fR[\fB!\fR]\fISTATUS\fR[\fB,\fISTATUS\fR...]]\ + [\fB\-\-restart\-on\-signal=\fR[\fB!\fR]\fISIG\fR[\fB,\fISIG\fR...]]\ [\fB\-\-sentinel\fR]\ @@ -103,2 +105,26 @@ terminates. Unless the \fB\-\-pid\-from\fR option is given, \fB\-\-pid\-from=FILE:\fIFILENAME\fR will be assumed. +.PP +In sentinel mode, it is possible to restart the program if it +terminates with a specific exit code or on a specific signal. This is +controlled by the \fB\-\-restart\-on\-exit\fR and +\fB\-\-restart\-on\-signal\fR options. Use this feature to ensure the +service provided by the program won't get terminated because of +hitting a bug or encountering an unforeseen external condition. For +example, the following two options will ensure that the program will +be terminated only if it exits with status 0 or it is terminated by +SIGTERM or SIGQUIT signal: +.EX +--restart-on-exit='!0' --restart-on-signal='!TERM,QUIT' +.EE +.PP +If restarts are requested, \fBgenrc\fR will control how often it has +to restart the program using the same algorithm as +.B init (8). +Namely, if the program is restarted more than 10 times within two +minutes, \fBgenrc\fR will disable subsequent restarts for the next +5 minutes. If the \fB\-\-create\-pidfile\fR option was used, the +PID of the controlling \fBgenrc\fR process will be stored in the +file during that interval. If the \fBSIGHUP\fR signal is delivered +during the sleep interval, the sleep will be broken prematurely and +the program restarted again. .SS status @@ -190,5 +216,33 @@ Where to look for PIDs of the running programs. .TP +\fB\-\-restart\-on\-exit=\fR[\fB!\fR]\fISTATUS\fR[\fB,\fISTATUS\fR...] +This option takes effect when used together with +\fB\-\-sentinel\fR. If the program terminates with one of status +codes listed as the argument to this option, it will be immediately +restarted. The exclamation mark at the start of the list inverts the +set, e.g. \fB\-\-restart\-on\-exit='!0,1'\fR means restart unless the +program exit code is 0 or 1. Note the use of quotation to prevent the +\fB!\fR from being interpreted by the shell. +.TP +\fB\-\-restart\-on\-signal=\fR[\fB!\fR]\fISIG\fR[\fB,\fISIG\fR...] +This option takes effect when used together with +\fB\-\-sentinel\fR. If the program terminates due to receiving one of +the signals from this list, it will be immediately restarted. Each +\fISIG\fR is either a signal number, or a signal name, as listed in +.BR signal (7). +The \fBSIG\fR prefix can be omitted from the signal name. Names are +case-insensitive. Thus, \fB1\fR, \fBHUP\fR, \fBSIGHUP\fR, and +\fBsighup\fR all stand for the same signal. +.sp +The exclamation mark at the start of the list complements the signal +set, so that e.g. \fB\-\-restart\-on\-signal='!TERM,QUIT,INT'\fR will +restart the program unless it terminates on one of the listed signals. +.TP \fB\-\-sentinel\fR \fIPROGRAM\fR runs in foreground; disconnect from the controlling -terminal, run it and act as a sentinel. +terminal, start it and run in background until it terminates. The +program's stdout and stderr are sent to the syslog facility +\fBdaemon\fR, priorities \fBinfo\fR and \fBerr\fR, correspondingly. + +See the options \fB\-\-restart\-on\-exit\fR and +\fB\-\-restart\-on\-signal\fR for details on how to restart the program. .TP |