1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH LAUNCHTOOL 1 "october 03, 2002"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
launchtool \- run a command supervising its execution.
.SH SYNOPSIS
.B launchtool
.RI [ options ]
.RI [ command ]
.br
.SH DESCRIPTION
\fBlaunchtool\fP is a tool that runs a user-supplied command and can supervise
its execution in many ways, such as controlling its environment, blocking
signals, logging its output, changing user and group permissions, limiting
resource usage, restarting it if it fails, running it continuously and turning
it into a daemon.
.P
\fBlaunchtool\fP is fully configurable, both through the commandline and using
configuration files. Configuration files can be made executable and start with
\*(lq#!/usr/bin/launchtool -C\*(rq, to create daemons using simpler commands.
.SH INVOCATION
.P
\fBlaunchtool\fP executes the command it finds in the commandline, via switches
or the configuration file. All non-switch parameters are concatenated to the
command, that will be executed using \*(lq/bin/sh -c\*(rq.
.P
\fBlaunchtool\fP default mode of execution is to run the command normally and
return its exit status. All features are disabled by default and activated
using commandline options or values in the configuration file. Commandline
options override configuration files.
.P
\fBlaunchtool\fP sessions are identified by a tag that is used both to mark the
command output in logfiles and to identify running sessions to check if they
have already been started or send them a signal without specifying the process
PID.
.SH OPTIONS
\fBlaunchtool\fP follows the usual GNU command line syntax, with long options
starting with two dashes (`-').
.TP
.B \-?, \-\-help
Display a detailed help message with a summary of all options.
.TP
.B \-\-usage
Display a brief usage message.
.TP
.B \-k, \-\-kill[=signal]
Kill a running launchtool with the specified signal (15 by default) and exit. No
signal name parsing is (yet) provided, so the signal must be specified by its
number.
.TP
.B \-\-check
Check if another launchtool is running, then exit.
.TP
.B \-\-showcfg
Process config files and commandline, show the resulting configuration and exit.
.TP
.B \-V, \-\-version
Print version and exit.
.TP
.B \-t, \-\-tag=tag, \*(lqtag\*(rq
Tag used to identify the session
.TP
.B \-C, \-\-config=file
Read configuration data from \*(lqfile\*(rq. Defaults to /etc/launchtool/<tag>.conf
.TP
.B \-v, \-\-verbose, \*(lqverbose\*(rq
Enable verbose output.
.TP
.B \-\-no\-verbose
Disable verbose output.
.TP
.B \-\-debug, \*(lqdebug\*(rq
Enable debug output (includes --verbose output).
.TP
.B \-\-no\-debug
Disable debug output.
.TP
.B \-c, \-\-command=cmd, \*(lqcommand\*(rq
Command to execute.
.TP
.B \-\-visible\-tag=tag, \*(lqvisible tag\*(rq
Tag to use for pidfiles and logfiles instead of \*(lqlaunchtool-<tag>\*(rq.
.TP
.B \-d, \-\-daemon, \*(lqdaemon\*(rq
Fork to background and detach from terminal, becoming a daemon.
.TP
.B \-n, \-\-no\-daemon
Don't become a daemon.
.TP
.B \-\-pidfile, \*(lqpidfile\*(rq
Create a pidfile (default when --daemon is used).
.TP
.B \-\-no\-pidfile
Don't create a pidfile (default when --daemon is not used).
.TP
.B \-\-piddir=dir, \*(lqpiddir\*(rq
Directory where pidfiles are stored (default to /var/run).
.TP
.B \-\-chroot=dir, \*(lqroot dir\*(rq
Chroot to this directory before running the command.
.TP
.B \-\-chdir=dir, \*(lqstart dir\*(rq
Chdir to this directory before running the command (default to '.' or '/' if
--daemon is present).
.TP
.B \-u, \-\-user=user, \*(lquser\*(rq
User privileges to run the command with.
.TP
.B \-g, \-\-group=group, \*(lqgroup\*(rq
Group privileges to run the command with.
.TP
.B \-\-umask=mask, \*(lqumask\*(rq
Set this umask before running the command.
.TP
.B \-L, \-\-infinite-runs, \*(lqinfinite runs\*(rq
Never give up restarting the command if it fails.
.TP
.B \-\-no\-infinite-runs
Give up restarting the command after a certain number of failures.
.TP
.B \-\-wait\-times=t1,t2,... , \*(lqwait times\*(rq
List of times (in seconds) to wait after a program failure before restarting
it. If not specified, failed commands will not be restarted.
.TP
.B \-\-good\-running\-time=seconds, \*(lqgood running time\*(rq
Minimum running time needed to restart for the first wait time.
.TP
.B \-\-forwarded\-signals=sig1,sig2,... , \*(lqforwarded signals\*(rq
List of signals (in name or in number) to be forwarded to the command.
.TP
.B \-\-blocked\-signals=sig1,sig2,... , \*(lqblocked signals\*(rq
List of signals (in name or in number) to be blocked before running the command.
.TP
.B \-\-limit\-cpu=seconds, \*(lqcpu limit\*(rq
CPU time limit for the command (see setrlimit(2)).
.TP
.B \-\-limit\-file\-size=1024b-blocks, \*(lqfile size limit\*(rq
File size limit for the command (see setrlimit(2)).
.TP
.B \-\-limit\-data\-memory=1024b-blocks, \*(lqdata memory limit\*(rq
Data memory size limit for the command (see setrlimit(2)).
.TP
.B \-\-limit\-process\-count=count, \*(lqprocess count limit\*(rq
Process count limit for the command (see setrlimit(2)).
.TP
.B \-\-limit\-open\-files=count, \*(lqopen files limit\*(rq
Open files limit for the command (see setrlimit(2)).
.TP
.B \-\-limit\-core\-size=1024b-blocks, \*(lqcore size limit\*(rq
Core file size limit for the command (see setrlimit(2)).
.TP
.B \-\-restrict\-environment, \*(lqrestrict environment\*(rq
Restrict the child environment.
.TP
.B \-\-no-restrict\-environment
Copy all environment variables to the child environment.
.TP
.B \-\-allowed\-env\-vars=var1,var2,... , \*(lqallowed env vars\*(rq
List of environment variables to be copied to the child when the environment is
restricted.
.TP
.B \-\-log\-launchtool\-output=target, \*(lqlaunchtool output\*(rq
Target of the launchtool output (ignore, stdout, stderr, file:filename or
syslog:identity,facility,level).
.TP
.B \-\-log\-launchtool\-errors=target, \*(lqlaunchtool errors\*(rq
Target of the launchtool error messages (ignore, stdout, stderr, file:filename or
syslog:identity,facility,level).
.TP
.B \-\-log\-child\-output=target, \*(lqcommand output\*(rq
Target of the child output (ignore, stdout, stderr, file:filename or
syslog:identity,facility,level).
.TP
.B \-\-log\-child\-errors=target, \*(lqcommand errors\*(rq
Target of the child error messages (ignore, stdout, stderr, file:filename or
syslog:identity,facility,level).
.TP
.B \-\-silent\-restart\-status=value, \*(lqsilent restart status\*(rq
Return value used by the child to explicitly request a restart (feature
disabled if not specified).
.TP
.B \-\-silent\-restart\-time=seconds, \*(lqsilent restart time\*(rq
Time to wait before restarting the child after an explicit restart request.
.TP
.B \-\-stats, \*(lqstats\*(rq
Produce some statistics when the command terminates (implied by --verbose).
.TP
.B \-\-no\-stats
Do not produce statistics when the command terminates.
.SH LOGGING TARGETS
Logging targets are specified with a target name and its optional parameters,
separated by a colon (\*(lq:\*(rq).
.P
Possible target configurations are:
.TP
.B ignore
Output is just discarded.
.TP
.B stdout
Output goes to the standard output stream.
.TP
.B stderr
Output goes to the standard error stream.
.TP
.B file:filename
Output goes to the file \*(lqfilename\*(rq.
.TP
.B syslog:identity,facility,level
Output goes to syslog, with the given identity (a string identifying the
logger), facility (see syslog(3)) and level (see syslog(3)).
.SH CONFIGURATION FILE
The configuration file is a sequence of \*(lqkey = value\*(rq lines. Empty lines and
lines starting with '#' are ignored.
.P
The possible keys have been listed in the OPTIONS section next to the
corresponding commandline switch.
.P
Boolean (yes/no) values can take the values \*(lqyes\*(rq, \*(lqno\*(rq, \*(lqtrue\*(rq, \*(lqfalse\*(rq, \*(lq0\*(rq
and \*(lq1\*(rq.
.SH EXAMPLES
.P
.nf
# Running a command normally
launchtool -t tag 'echo "Hello, world!"'
# Run a command restarting it if it fails:
launchtool -t tag --wait-times=1,1,1,3,3,3,10,10,10 'my_wonderful_server'
# Run a command, with restrictions, restarting it if it fails, as a daemon
launchtool -t myserver -d --user=myserver --chroot=/var/myserver \\
--limit-process-count=5 --limit-open-files=10 \\
--wait-times=1,1,1,3,3,3,10,10,10 \\
--infinite-runs --stats \\
--log-launchtool-output=syslog:myserver,LOG_DAEMON,LOG_INFO \\
--log-launchtool-errors=syslog:myserver,LOG_DAEMON,LOG_ERR \\
--log-child-output=syslog:myserver,LOG_DAEMON,LOG_INFO \\
--log-child-errors=syslog:myserver,LOG_DAEMON,LOG_ERR \\
'my_experimental_server'
# Same thing, using a configuration file
tag = myserver
command = my_wonderful_server
daemon = yes
stats = yes
user = myserver
root dir = /var/myserver
process count limit = 5
open files limit = 10
wait times = 1,1,1,3,3,3,10,10,10
infinite runs = yes
launchtool output = syslog:myserver,LOG_DAEMON,LOG_INFO
launchtool errors = syslog:myserver,LOG_DAEMON,LOG_ERR
command output = syslog:myserver,LOG_DAEMON,LOG_INFO
command errors = syslog:myserver,LOG_DAEMON,LOG_ERR
# Transform a shell command in a polling daemon
# Make the file /tmp/have_mobile exist only if my cell phone is present in the
# IRDA discovery list
launchtool -t celldetect -d --silent-restart-time=5 --silent-restart-status=0 --user=nobody \\
"if grep -q SIEMENS /proc/sys/net/irda/discovery; then touch /tmp/have_mobile; else rm -f /tmp/have_mobile; fi ; exit 0"
# Ceck if the celldetect daemon is running
launchtool -t celldetect --check
# Kill the celldetect daemon launched with the command above
launchtool -t celldetect -k
# Same polling daemon, with an executable configuration file
#!/usr/bin/launchtool -C
tag = celldetect
command = if grep -q SIEMENS /proc/sys/net/irda/discovery; then touch /tmp/have_mobile; else rm -f /tmp/have_mobile; fi ; exit 0
daemon = yes
user = nobody
silent restart time = 5
silent restart status = 0
# Ceck if the celldetect daemon is running, using the executable configuration
# file
celldetect --check
# Kill the celldetect daemon using the executable configuration file
celldetect -k
.fi
.SH SEE ALSO
.BR syslog (3),
.BR setrlimit (2).
.SH AUTHOR
\fBlaunchtool\fP has been written by Enrico Zini <enrico@debian.org>.
|