]> git.neil.brown.name Git - metad.git/blob - metad.texi
Assorted reformating
[metad.git] / metad.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename metad.info
4 @settitle Metad -- The Daemon for controlling daemons.
5 @setchapternewpage off
6 @c %**end of header
7
8 @ifinfo
9
10 @node Top, Introduction, (dir), (dir)
11 @comment  node-name,  next,  previous,  up
12 @top Metad
13
14 @end ifinfo
15
16 @titlepage
17 @title METAD
18 @subtitle The Daemon for controlling Daemons
19 @author The School of Computer Science and Engineering
20 @author Computing Support Group
21 @end titlepage
22
23 @menu
24 * Introduction::                
25 * Configuration::               
26 * Control::                     
27 * Logs::                        
28
29  --- The Detailed Node Listing ---
30
31 Introduction
32
33 * Functionality::               
34 * Usefulness::                  
35
36 Functionality
37
38 * Service Classes::             
39
40 Configuration
41
42 * Invocation::                  
43 * Config file format::          
44 * General options::             
45 * The Daemon Class::            
46 * The Listener Class::          
47 * The Stream Class::            
48
49 Config file format
50
51 * Service Name and Class::      
52 * Options::                     
53 * Program and arguments::       
54
55 General options
56
57 * Max::                         
58 * Dir::                        
59 * User::                        
60 * Pidfile::                     
61 * Watch_output::                
62 * Enabled::                     
63 * Crash::                       
64
65 The Daemon Class
66
67 * Min::                         
68 * Period::                      
69
70 Control
71
72 * Disabling and Enabling::      
73 * Killing::                     
74 * Starting::                    
75 * Listing::                     
76 * Reread and Restart::          
77 * Broadcast::                   
78 * metac::                       
79 @end menu
80
81 @node Introduction, Configuration, Top, Top
82 @chapter Introduction
83
84 @emph{Metad} is a program for running other programs.
85 Unlike the shell (which also satisfies that description), Metad runs
86 background system programs rather than foreground user programs.
87
88 Metad serves a purpose similar to @code{cron}, @code{inetd}, and
89 @code{init}, and could replace them all.
90 The significant enhancement metad has over these programs is that it is
91 easily controllable, from anywhere on the network.
92
93 @menu
94 * Functionality::               
95 * Usefulness::                  
96 @end menu
97
98
99 @node Functionality, Usefulness, Introduction, Introduction
100 @section Functionality
101
102 The basic function of metad is to run programs in response to certain
103 stimuli.
104 These stimuli can be time passing, other programs exiting, I/O
105 activity being possible on some socket, or direct request.
106
107 Metad will also, on request, send signals to any of the programs that it
108 has run, report on its status, and disable or re-enable any of the
109 services it offers. The requests are sent to metad over the network by
110 the @code{metac} program described below in @xref{metac}.
111
112 Metad gets a list of services that it should provide from a
113 configuration file (@pxref{Config file format}). This file describes,
114 for each service,
115 what program to run, how to run it, and when to run it.
116
117 The @emph{what} part is simply the name of the file containing the
118 program.
119 The @emph{how} part includes command line arguments, working directory
120 and user id.
121 The @emph{when} part is probably most interesting.
122
123 @menu
124 * Service Classes::             
125 @end menu
126
127 @node Service Classes,  , Functionality, Functionality
128 @subsection Service Classes
129 Meta understands a small number of types or @dfn{classes} or service,
130 each of which respond to different stimuli.
131 @table @code
132 @item daemon
133 The @code{daemon} is the simplest form for service
134 (and the only one currently implemented).
135 A @code{daemon} service will run its program either repeatedly,
136 periodically, on request, or any combination of these.
137 It may allow multiple instances of the program to be running at once,
138 and can impose an upper and lower limit on this number.
139
140 It may also be able to run its program just once (at startup) or on
141 completion of some other services program (not implemented yet).
142
143 @item listener
144 The @code{listener} class supports programs which need to listen for input on
145 a network port.
146 Metad will set up the network port and will wait for activity. When
147 activity is noticed, metad will run the program, passing it the network
148 port, so that it can do what ever is needed.
149 When the program exits, metad will resume waiting for more activity.
150
151 The port can be a udp/ip port or a tcp/ip port.
152
153 This is similar to the dgram/wait service of @code{inetd} and the
154 stream/wait service of some implementations of @code{inetd}.
155
156 @item steam
157 The @code{stream} class supports programs which need to respond to
158 network stream connections, such as @code{telnetd} or @code{fingerd}.
159 Metad will listen on a stream socket for a connection request.
160 It will then accept the connection, possibly verify the source, and then
161 run the program passing the the connection.
162
163 As with all metad services, it is possible to limit the number of
164 program instances which are running concurrently.
165
166 @end table
167
168 @node Usefulness,  , Functionality, Introduction
169 @section Usefulness
170
171 The main goal that metad was developed to meet, was to assist in the
172 development of various daemon services which needed to be run on various
173 machines around the network.
174 The sort of assistance required involved:
175 @itemize @bullet
176 @item
177 Restarting a daemon if it dies, possibly reporting the death.
178 @item
179 Killing a restarting a daemon when a new version is installed.
180 @item
181 Taking control of new daemons.
182 @item
183 Running some program on all machines on the network.
184 @end itemize
185
186 This goal lead to the @emph{daemon} class and the @emph{metac} control
187 program being created.
188 The @emph{listener} and @emph{stream} classes are later additions
189 brought about due to a dissatisfaction with inetd.
190
191 Say something about shortcomings?? hiding failure and not being able to
192 control named.
193
194 @node Configuration, Control, Introduction, Top
195 @chapter Configuration
196
197 @menu
198 * Invocation::                  
199 * Config file format::          
200 * General options::             
201 * The Daemon Class::            
202 * The Listener Class::          
203 * The Stream Class::            
204 @end menu
205
206 @node Invocation, Config file format, Configuration, Configuration
207 @section Invocation
208
209 Metad takes precisely two command line arguments.
210 The first is used as the name of the configuration file, as described
211 below.
212 The second is used as the name of the file which contains the metad
213 program.
214 This is used when metad is asked to restart itself (for instance, when a
215 new version has been installed).
216
217 Metad also inspects its "zeroth" argument. If this is the string
218 @samp{metad-restart}, then metad assumes that it has just restarted
219 itself and looks on @strong{stdin} for a description of the previous state
220 (in particular, what processes were running).
221
222
223 @node Config file format, General options, Invocation, Configuration
224 @section Config file format
225
226 The configuration file for metad simply lists the different services
227 that metad should monitor, one per line.
228 Any line that is not empty or a comment line (beginning with a hash or
229 number sign @samp{#}) is a service line.
230 Each line is broken up into words on spaces and tabs. Spaces and tabs
231 can be preserved in words by quoting them with single or double quotes.
232 Quotes and back slashes can be preserved by prefixing them with back
233 slashes.
234
235 The words are the services name, its class, some options, the program
236 name, and the programs arguments.
237 The program name is distinguished from options by the fact that it
238 starts with a slash.
239
240 @menu
241 * Service Name and Class::      
242 * Options::                     
243 * Program and arguments::       
244 @end menu
245
246 @node Service Name and Class, Options, Config file format, Config file format
247 @subsection Service Name and Class
248
249 The service name is any unique string of characters and is
250 uninterpreted.
251 In the future, services may be grouped based on a common prefix of the
252 name. This prefix would be up to a period.
253
254 The class name is one of a predefined set of classes, currently only
255 @samp{daemon} is supported.
256
257 @node Options, Program and arguments, Service Name and Class, Config file format
258 @subsection Options
259
260 The options provide details one how and when a service will run a
261 program.
262 Some options are applicable to all classes of service. These are the
263 General options described below (@pxref{General options}).
264 Others are specific to a class and are detail under the particular class
265 below.
266
267 Most options take the form of @samp{@var{name}=@var{value}}.
268
269 @node Program and arguments,  , Options, Config file format
270 @subsection Program and arguments
271 As mentioned, the program is the first word on the line which begins
272 with a slash. The full path name of the program must be given.
273 Subsequent words are passed to the program as an argument list. There
274 must always be at least one argument, which is normally the name of the program.
275
276 @node General options, The Daemon Class, Config file format, Configuration
277 @section General options
278
279 The General options are applicable to all classes of service. The
280 default value can be different with different services.
281 The default listed below is the default used for the @code{daemon} service.
282 @menu
283 * Max::                         
284 * Dir::                        
285 * User::                        
286 * Pidfile::                     
287 * Watch_output::                
288 * Enabled::                     
289 * Crash::                       
290 @end menu
291
292 @node Max, Dir, General options, General options
293 @subsection Max
294
295 The @dfn{max} option sets the maximum number of concurrent processes
296 that can be running for a particular service. The default for
297 @code{daemon}s is one. Format is @code{max=@var{nn}} when @var{nn} is a
298 decimal integer.
299
300 @node Dir, User, Max, General options
301 @subsection Dir
302
303 The @dfn{dir} option sets the working directory for processes run for
304 this service. The default is the same as metad's working directory.
305 A full path name should be given.
306
307 @node User, Pidfile, Dir, General options
308 @subsection User
309
310 The @dfn{user} option specifies an alternate userid to for processes run
311 for this service. Metad must be run by @strong{root} for this to work.
312 The default is to leave the user id unchanged from that of metad.
313
314 When setting the userid, the groups ids are also set to those for the
315 named user.
316
317 @node Pidfile, Watch_output, User, General options
318 @subsection Pidfile
319
320 Some daemon programs insist on forking and continuing to perform useful
321 work in the child while the parent exits. This is useful in many
322 circumstances, but makes it difficult for metad to continue to monitor
323 and control the program.
324 To help with this, the @dfn{pidfile} option specifies the name of a file which the program
325 might write the process id of the forked child.
326
327 When a process that metad has started exits, metad checks the
328 appropriate @var{pidfile} to see if it was written since the process
329 started, and if it contains the pid of an active process.
330 If this check succeeds, then metad assumes that the process found is
331 carrying one the work of the original process.
332
333 This process will then be the target of any @strong{kill} commands, and
334 it will be treated just as though it were the original process.
335
336 @node Watch_output, Enabled, Pidfile, General options
337 @subsection Watch_output
338
339 If the @dfn{watch_output} option is listed for a service, then metad
340 will connect the standard output and standard error streams of any
341 processes started for that service to a pipe.
342 Metad will monitor the pipe for two purposes.
343
344 @enumerate
345 @item
346 Any data received from the pipe will be logged with syslog as an
347 informational message about the processes.
348 @item
349 Metad will assume that the program is still active until an end-of-file
350 is read on the pipe --- even if the process that metad first started exits.
351 @end enumerate
352
353 @node Enabled, Crash, Watch_output, General options
354 @subsection Enabled
355
356 The @dfn{enabled} option can be used to enabled or disable a service at
357 startup. The value can be one of the words @samp{yes} and @samp{no}. The
358 default value is @samp{yes}.
359
360 @node Crash,  , Enabled, General options
361 @subsection Crash
362
363 The @dfn{crash} option specifies a program to run after a crash (exit
364 due to signal). The program is expected to clean up or report the
365 problem.
366 Currently this is unimplemented so details are scarce.
367
368 @node The Daemon Class, The Listener Class, General options, Configuration
369 @section The Daemon Class
370
371 The @code{daemon} class understands two more options. They are @samp{min}
372 and @samp{period}.
373 @menu
374 * Min::                         
375 * Period::                      
376 @end menu
377
378 @node Min, Period, The Daemon Class, The Daemon Class
379 @subsection Min
380
381 The @dfn{min} option specifies the minimum number of processes that
382 should be running for the service. If fewer than that minimum are
383 running, new processes will be started until the minimum is reached.
384
385 The default minimum is zero.
386
387 @node Period,  , Min, The Daemon Class
388 @subsection Period
389
390 The @dfn{period} option specifies how frequently a daemon service should
391 start a new processes. The value should be a decimal integer with a
392 single character suffix.
393 Suffixes are @samp{s} for seconds, @samp{m} for minutes, @samp{h} for
394 hours, or @samp{d} for days. If no suffix is given, seconds is assumed.
395
396 If this period passes without a processes being start (or attempted to
397 be started), metad will attempt to start a process to execute the
398 services program. If the maximum number of processes are already
399 running, the attempt will fail, but will still be recorded as an attempt
400 and metad will wait for the period to pass again.
401
402 @node The Listener Class, The Stream Class, The Daemon Class, Configuration
403 @section The Listener Class
404
405 The Listener class is not implemented yet, so details are scarce.
406 It is expected to need a port option (service/protocol, e.g. pop3/tcp).
407
408 @node The Stream Class,  , The Listener Class, Configuration
409 @section The Stream Class
410
411 The Stream class is not yet implemented, so details are not available.
412 It is expected to need a port option (service/protocol e.g. telnet/tcp)
413 and multiple access options (access+.domain access-@@netgroup
414 access+nnn.nnn/16)
415
416 The identity of the peer will probably be provided in the environment,
417 e.g. METAD_PEER=host.domain.au:port
418
419
420 @node Control, Logs, Configuration, Top
421 @chapter Control
422
423 A particularly useful feature of metad is the fact that it can be
424 controlled from anywhere on the network.
425 To achieve this, metad understands a fairly simple command protocol.
426 Commands can be sent either over a tcp/ip connection, in which case a
427 response is returned, or via a udp/ip datagram. The use of datagrams
428 means that a command can be broadcast to all metads on a given subnet.
429
430 As one of the commands the metad will obey is to rebroadcast a command,
431 commands can easily be broadcast around a medium sized internet.
432
433 @menu
434 * Disabling and Enabling::      
435 * Killing::                     
436 * Starting::                    
437 * Listing::                     
438 * Reread and Restart::          
439 * Broadcast::                   
440 * metac::                       
441 @end menu
442
443 @node Disabling and Enabling, Killing, Control, Control
444 @section Disabling and Enabling
445
446 Individual services can be disabled and re-enabled.
447
448 When disabled a service will not start any new processes, though it will
449 not attempt to stop and processes that are already running.
450 A disabled service that would normally listen for some specific network
451 activity will not listen for that activity at all.
452
453 Services are disabled be sending the command @samp{disable
454 @var{servicename}} and are enabled with the command @samp{enabled
455 @var{servicename}}.
456
457 These can be easily sent with metac using option @samp{-D @var{service}}
458 and @samp{-E @var{service}}.
459
460 @node Killing, Starting, Disabling and Enabling, Control
461 @section Killing
462
463 Killing a process involves sending a Unix signal to the process. This
464 does not always cause it to die.
465
466 To send a signal to all processes for a particular service, the command
467 is @samp{kill @var{signum} @var{service}}.
468 To send to a specific process, its process id must be given instead of
469 the servicename.
470
471 Sending signal 15 (SIGTERM) can easily be done with metac using @samp{-K
472 @var{service}} or @samp{-K @var{processid}}.
473
474 @node Starting, Listing, Killing, Control
475 @section Starting
476
477 Some classes (currently only daemon, definitely not stream, probably
478 listener) will start a new process on request. This request is sent with
479 the @samp{run} command.
480 Optional extra information can be sent with the run command to modify
481 the action of the started program. This is passed the the program
482 through the environment variable @emph{METAD_ARG}.
483 The command to run a new process is
484 @samp{run @var{service} @var{extra-information}}.
485
486 If no extra information is to be sent, this can be done with metac using
487 @samp{-r @var{service}}. To send extra information simply add @samp{-a
488 @var{args}}.
489
490
491 @node Listing, Reread and Restart, Starting, Control
492 @section Listing
493
494 Metad can be asked to send a report on the services it is maintaining
495 including the current processes which are running. The information is
496 returned in a binary format which is only understood by metac.
497 Either a single service can be listed (command @samp{list @var{service}}, option
498 @samp{-l @var{service}}) or all services can be listed.
499 (command @samp{list}, option @samp{-L}).
500
501 I should say something about the listing that is returned... later.
502
503 @node Reread and Restart, Broadcast, Listing, Control
504 @section Reread and Restart
505
506 The @samp{reread} command causes metad to reread its config file.
507 New services can be added and options, programs and arguments can be
508 changed. If a service has be removed from the config file, then the
509 service is not forgotten by metad (it might have running processes) but
510 it is disabled.
511
512 The @samp{restart} command causes to metad to exec a new instance of
513 itself, replacing the old one.
514 Information about what processes are running for which service is passed
515 through so that there will be no undue interruption of
516 service. Processes for services which no longer exist will be simply
517 forgotten.
518
519 This is useful after installing a new version of metad.
520
521 @node Broadcast, metac, Reread and Restart, Control
522 @section Broadcast
523
524 The @samp{broadcast} command will broadcast it arguments as a command to
525 all nearby metads (on the same subnet). This may cause the command to be
526 delivered to some metads multiple times (if they are on machines with
527 multiple interfaces). As most metad commands are fairly idempotent, this
528 is not likely to be a problem, but should be considered.
529
530 @node metac,  , Broadcast, Control
531 @section metac
532
533 Metac is the program to use to send commands to metad.
534 It takes are arguments a number of commands and a number of hosts to
535 send the commands to. It may be asked to broadcast the commands, or to
536 send them via datagrams. The default it to send them over a stream
537 connection.
538
539 Commands and host names may be intermixed on the command line. All
540 commands will still be sent to all hosts.
541
542 Commands can be given explicitly using the @samp{-C} flag, or more
543 briefly using one of the command flags.
544 The flags understood by metac are:
545 @table @samp
546 @item -u
547 Send (udp) datagrams, rather than making stream connection.
548 @item -b
549 Broadcast datagrams on all network interfaces.
550 @item -B
551 All commands should be sent with a @samp{broad } prefix so that the
552 responding metad will broadcast the command in its subnet.
553 @item -v
554 Be verbose in reporting responses --- what does this mean???
555 @item -C command
556 Send the given command as is.
557 @item -r service
558 Send a @samp{run @var{service}} command.
559 @item -a args
560 Append the @var{args} to the previous @samp{-r} command;
561 @item -l service
562 Ask for a listing of the named service.
563 @item -L
564 Ask for a listing of all services.
565 @item -D service
566 Send a @samp{disable @var{service}} command.
567 @item -E service
568 Send a @samp{enable @var{service}} command.
569 @item -K pid/service
570 Send a @samp{kill 15 @var{pid/service}} command to kill the process or
571 service.
572 @item -R
573 Send a @samp{reread} command.
574 @item -X
575 Send an @samp{exit} command. (but thats not documented...);.
576 @item -V
577 Display version number of metac and send request for version information
578 to metads.
579 @end table
580
581 @node Logs,  , Control, Top
582 @chapter Logs
583
584 @contents
585 @bye