chiark / gitweb /
set period interval to 30s
[inn-innduct.git] / doc / man / innduct.8
1 .TH INNDUCT 8
2 .SH NAME
3 innduct \- quickly and reliably stream Usenet articles to remote site
4 .SH SYNOPSIS
5 .B innduct
6 .RI [ options ]
7 .I site
8 .RI [ fqdn ]
9 .SH DESCRIPTION
10 .B innduct
11 implements NNTP peer-to-peer news transmission including the streaming
12 extensions, for sending news articles to a remote site.  It is
13 intended as a replacement for
14 .B innfeed
15 or
16 .BR nntpsend
17 and
18 .BR innxmit .
19
20 You need to run one instance of innduct for each peer site.  innduct
21 manages its interaction with
22 .BR innd ,
23 including flushing the feed as appropriate, etc., so that articles are
24 transmitted quickly, and manages the retransmission of its own
25 backlog.  innduct includes the locking necessary to avoid multiple
26 simutaneous invocations.
27
28 By default, innduct reads the default feedfile corresponding to
29 the site
30 .I site
31 (ie
32 .IR pathoutgoing / site )
33 and feeds it via NNTP, streaming if possible, to the host
34 .IR fqdn .
35 If
36 .I fqdn
37 is not specified, it defaults to
38 .IR site .
39
40 innduct daemonises after argument parsing, and all logging (including
41 error messages) are sent to syslog (facility
42 .BR news ).
43
44 The best way to run innduct is probably to periodically invoke it
45 for each feed (e.g. from cron), passing the
46 .B \-q
47 option to arrange that innduct silently exits if an instance is
48 already running for that site.
49 .SH GENERAL OPTIONS
50 .TP
51 .BR \-f | \-\-feedfile= \fIDIR\fR / |\fIPATH\fR
52 Specifies the
53 .I feedfile
54 to read, and indirectly specifies the paths to
55 be used for various associated files (see FILES, below).
56 If specified as
57 .IB DIR /
58 it is taken as a directory to use, and the actual feed file used is
59 .IR path / site .
60 If
61 .I PATH
62 or
63 .I DIR
64 does not start with a
65 .BR / ,
66 it is taken to be relative to
67 .IR pathoutgoing
68 from inn.conf.
69 The default is
70 .IR site .
71 .TP
72 .BR \-q | \-\-quiet-multiple
73 Makes innduct silently exit (with status 0) if another innduct holds
74 the lock for the site.  Without \fB-q\fR, this causes a fatal error to
75 be logged and a nonzero exit.
76 .TP
77 .BR \-\-no-daemon
78 Do not daemonise.  innduct runs in the foreground and all messages
79 (including all debug messages) are written to stderr rather than
80 syslog.  A control command line is also available on stdin/stdout.
81 .TP
82 .BI \-\-no-streaming
83 Do not try to use the streaming extensions to NNTP (for use eg if the
84 peer can't cope when we send MODE STREAM).
85 .TP
86 .BI \-\-no-filemon
87 Do not try to use the file change monitoring support to watch for
88 writes by innd to the feed file; poll it instead.  (If file monitoring
89 is not compiled in, this option just downgrades the log message which
90 warns about this situation.)
91 .TP
92 .BR \-C | \-\-inndconf= \fIFILE\fR
93 Read
94 .I FILE
95 instead of the default
96 .BR inn.conf .
97 .TP
98 .BI \-\-port= PORT
99 Connect to port
100 .I PORT
101 at the remote site rather than to the NNTP port (119).
102 .TP
103 .BI \-\-chdir= PATHRUN
104 Change directory to
105 .IR pathrun
106 at startup.  The default is
107 .I pathrun
108 from inn.conf.
109 .TP
110 .BR \-\-cli= \fICLI-DIR\fR / |\fICLI-PATH\fR| none
111 Listen for control command line connections on
112 .IB CLI-DIR / site
113 (if the value ends with a
114 .BR /)
115 or
116 .I CLI-PATH
117 (if it doesn't).  See CONTROLLING INNDUCT, below.
118 Note that there is a fairly short limit on the lengths of AF_UNIX
119 socket pathnames.  If specified as
120 .IR CLI-DIR \fB/\fR,
121 the directory will be created with mode 700 if necessary.
122 The default is
123 .B innduct/
124 which means to create that directory in
125 .I PATHRUN
126 and listen on
127 .RB \fIPATHRUN\fR /innduct/ \fIsite\fR.
128 .TP
129 .BI \-\-help
130 Just print a brief usage message and list of the options to stdout.
131 .LP
132 See TUNING OPTIONS below for more options.
133 .SH CONTROLLING INNDUCT
134 If you tell innd to drop the feed, innduct will (when it notices,
135 which will normally be the next time it decides to flush) finish up the
136 articles it has in hand now, and then exit.  It is harmless to cause
137 innd to flush the feed (but innduct won't notice and flushing won't
138 start a new feedfile; you have to leave that to innduct).
139 .LP
140 If you want to stop innduct you can send it SIGTERM or SIGINT, or the
141 .B stop
142 control command, in which case it will report statistics so far and
143 quickly exit.  If innduct receives SIGKILL nothing will be broken or
144 corrupted; you just won't see some of the article stats.
145 .LP
146 innduct listens on an AF_UNIX socket (by default,
147 .IR pathrun \fB/innduct/\fR site ),
148 and provides a command-line interface which can be used to trigger
149 various events and for debugging.  When a connection arrives, innduct
150 writes a prompt, reads commands a line at a time, and writes any
151 output back to the caller.  (Everything uses unix line endings.)  The
152 cli can most easily be accessed with a program like
153 .I netcat-openbsd
154 (eg
155 .B nc.openbsd -U
156 .RI \fB/var/run/news/innduct/\fR site )
157 or
158 .IR socat .
159 The prompt is
160 .IR site \fB|\fR.
161 .LP
162 The following control commands are supported:
163 .TP
164 .B h
165 Print a list of all the commands understood.  This list includes
166 undocumented commands which mess with innduct's internal state and
167 should only be used by a developer in conjuction with the innduct
168 source code.
169 .TP
170 .B flush
171 Start a new feed file and trigger a flush of the feed.  (Or, cause
172 the
173 .I FLUSH-FINISH-PERIOD
174 to expire early, forcibly completing a previously started flush.)
175 .TP
176 .B stop
177 Log statistics and exit.  (Same effect as SIGTERM or SIGINT.)
178 .TP
179 .BR "dump q" | a
180 Writes information about innduct's state to a plain text file
181 .IR feedfile \fB_dump\fR.
182 This overwrites any previous dump.  innduct does not ever delete these
183 dump files.
184 .B "dump q"
185 gives a summary including general state and a list of connections;
186 .B "dump a"
187 also includes information about each article innduct is dealing with.
188 .TP
189 .B next blscan
190 Requests that innduct rescan for new backlog files at the next
191 .I PERIOD
192 poll.  Normally innduct assumes that any backlog files dropped in by
193 the administrator are not urgent, and it may not get around to
194 noticing them for
195 .IR BACKLOG-SCAN-PERIOD .
196 .TP
197 .B next conn
198 Resets the connection startup delay counter so that innduct may
199 consider making a new connection to the peer right away, regardless
200 of the setting of
201 .IR RECONNECT-PERIOD .
202 A connection attempt will still only be made if innduct feels that it
203 needs one, and innduct may wait up to
204 .I PERIOD
205 before actually starting the attempt.
206 .SH TUNING OPTIONS
207 You should not normally need to adjust these.  Time intervals may
208 specified in seconds, or as a number followed by one of the following
209 units:
210 .BR "s m h d" ,
211 .BR "sec min hour day" ,
212 .BR "das hs ks Ms" .
213 .TP
214 .BI \-\-max-connections= max
215 Restricts the maximum number of simultaneous NNTP connections
216 per peer to
217 .IR max .
218 There is no global limit on the number of connections used by all
219 innducts, as the instances for different sites are entirely
220 independent.
221 The default is
222 .BR 10 .
223 .TP
224 .BI \-\-max-queue-per-conn= per-conn-max
225 Restricts the maximum number of outstanding articles queued on any
226 particular connection to
227 .IR max .
228 (Non-streaming connections can only handle one article at a time.)
229 The default is
230 .BR 200 .
231 .TP
232 .BI \-\-max-queue-per-file= max
233 Restricts the maximum number articles read into core from any one
234 input file to
235 .IR max .
236 The default is
237 .B twice
238 .IR per-conn-max .
239 .TP
240 .BI \-\-feedfile-flush-size= bytes
241 Specifies that innduct should flush the feed and start a new feedfile
242 when the existing feedfile size exceeds
243 .IR bytes ;
244 the effect is that the innduct will try to avoid the various
245 batchfiles growing much beyond this size.  The default is
246 .BR 100000 .
247 .TP
248 .BI \-\-period-interval= PERIOD-INTERVAL
249 Specifies wakup interval and period granularity.
250 innduct wakes up every
251 .I PERIOD-INTERVAL
252 to do various housekeeping checks.  Also, many of the timeout and
253 rescan intervals (those specified in this manual as
254 .IR PERIOD )
255 are rounded up to the next multiple of
256 .IR PERIOD-INTERVAL .
257 The default is
258 .BR 30s .
259 .TP
260 .BI \-\-connection-timeout= TIME
261 How long to allow for a connection setup attempt before giving up.
262 The default is
263 .BR 200s .
264 .TP
265 .BI \-\-stuck-flush-timeout= TIME
266 How long to wait for innd to respond to a flush request before giving
267 up.  The default is
268 .BR 100s .
269 .TP
270 .BI \-\-feedfile-poll= TIME
271 How often to poll the feedfile for new articles written by innd
272 if file monitoring
273 .RI ( inotify
274 or equivalent) is not available.  (When file monitoring is available,
275 there is no need for periodic checks and we wake immediately up
276 whenever the feedfile changes.)
277 The default is
278 .BR 5s .
279 .TP
280 .BI \-\-no-check-proportion= PERCENT
281 If the moving average of the proportion of articles being accepted
282 (rather than declined) by the peer exceeds this value, innduct uses
283 "no check mode" - ie it just sends the peer the articles with TAKETHIS
284 rather than checking first with CHECK whether the article is wanted.
285 This only affects streaming connections.  The default is
286 .B 95
287 (ie, 95%).
288 .TP
289 .BI \-\-no-check-response-time= ARTICLES
290 The moving average mentioned above is an alpha-smoothed value with a
291 half-life of
292 .IR ARTICLES .
293 The default is
294 .BR 100 .
295 .TP
296 .BI \-\-reconnect-interval= RECONNECT-PERIOD
297 Limits initiation of new connections to one each
298 .IR RECONNECT-PERIOD .
299 This applies to reconnections if the peer has been down, and also to
300 ramping up the number of connections we are using after startup or in
301 response to an article flood.  The default is
302 .BR 1000s .
303 .TP
304 .BI \-\-flush-retry-interval= PERIOD
305 If our attempt to flush the feed failed (usually this will be because
306 innd is not running), try again after
307 .IR PERIOD .
308 The default is
309 .BR 1000s .
310 .TP
311 .BI \-\-earliest-deferred-retry= PERIOD
312 When the peer responds to our offer of an article with a 431 or 436
313 NNTP response code, indicating that the article has already been
314 offered to it by another of its peers, and that we should try again,
315 we wait at least
316 .IR PERIOD .
317 before offering the article again.  The default is
318 .BR 100s .
319 .TP
320 .BI \-\-backlog-rescan-interval= BACKLOG-SCAN-PERIOD
321 We scan the directory containing
322 .I feedfile
323 for backlog files at least every
324 .IR BACKLOG-SCAN-PERIOD ,
325 in case the administrator has manually dropped in a file there for
326 processing.
327 The default is
328 .BR 300s .
329 .TP
330 .BI \-\-max-flush-interval= PERIOD
331 We flush the feed and start a new feedfile at least every
332 .IR PERIOD
333 even if the current instance of the feedfile has not reached the size
334 threshold.
335 The default is
336 .BR 100000s .
337 .TP
338 .BI \-\-flush-finish-timeout= FLUSH-FINISH-PERIOD
339 If we flushed
340 .IR FLUSH-FINISH-PERIOD
341 ago, and are still trying to finish processing articles that were
342 written to the old feed file, we forcibly and violently make sure that
343 we can finish the old feed file: we abandon and defer all the work,
344 which includes unceremoniously dropping any connections on which
345 we've sent some of those articles but not yet had replies, as they're
346 probably stuck somehow.  The default is
347 .BR 2000s .
348 .TP
349 .BI \-\-idle-timeout= PERIOD
350 Connections which have had no activity for
351 .IR PERIOD
352 will be closed.  This includes connections where we have sent commands
353 or articles but have not yet had the responses, so this same value
354 doubles as the timeout after which we conclude that the peer is
355 unresponsive or the connection has become broken.
356 The default is
357 .BR 1000s .
358 .TP
359 .BI \-\-low-volume-thresh= "WIN-THRESH " \-\-low-volume-window= "PERIOD "
360 If innduct has only one connection to the peer, and has processed
361 fewer than
362 .I WIN-THRESH
363 articles in the last
364 .I PERIOD
365 and also no articles in the last
366 .IR PERIOD-INTERVAL
367 it will close the connection quickly.  That is, innduct switches to a
368 mode where it opens a connection for each article (or, perhaps, each
369 handful of articles arriving together).
370 The default is to close if fewer than
371 .BR 3
372 articles in the last
373 .BR 1000s .
374 .TP
375 .BI \-\-max-bad-input-data-ratio= PERCENT
376 We tolerate up to this proportion of badly-formatted lines in the
377 feedfile and other input files.  Every badly-formatted line is logged,
378 but if there are too many we conclude that the corruption to our
379 on-disk data is too severe, and crash; to successfully restart,
380 administrator intervention will be required.  This avoids flooding the
381 logs with warnings and also arranges to abort earlyish if an attempt
382 is made to process a file in the wrong format.  We need to tolerate a
383 small proportion of broken lines, if for no other reason than that a
384 crash might leave a half-blanked-out entry.  The default is
385 .BR 1
386 (ie, 1%).
387 .TP
388 .BI \-\-max-bad-input-data-init= LINES
389 Additionally, we tolerate this number of additional badly-formatted
390 lines, so that if the badly-formatted lines are a few but at the start
391 of the file, we don't crash immediately.
392 The default is
393 .BR 30
394 (which would suffice to ignore one whole corrupt 4096-byte disk block
395 filled with random data, or one corrupt 1024-byte disk block filled
396 with an inappropriate text file with a mean line length of at least
397 35).
398 .SH INNDUCT VS INNFEED/NNTPSEND/INNXMIT
399 .TP
400 .B innfeed
401 does roughly the same thing as innduct.  However, the way it receives
402 information from innd can result in articles being lost (not offered
403 to peers) if innfeed crashes for any reason.  This is an inherent
404 defect in the innd channel feed protocol.  innduct uses a file feed,
405 constantly "tailing" the feed file, and where implemented uses
406 .BR inotify (2)
407 to reduce the latency which would come from having to constantly poll
408 the feed file.  innduct is much smaller and simpler, at <4kloc to
409 innfeed's 25kloc.  innfeed needs a separate helper script or similar
410 infrastructure (of which there is an example in its manpage), whereas
411 innduct can be run directly and doesn't need help from shell scripts.
412 However, innfeed is capable of feeding multiple peers from a single
413 innfeed instance, whereas each innduct process handles exactly one
414 peer.
415 .TP
416 .B nntpsend
417 processes feed files in batch mode.  That is, you have to periodically
418 invoke nntpsend, and when you do, the feed is flushed and articles
419 which arrived before the flush are sent to the peer.  This introduces
420 a batching delay, and also means that the NNTP connection to the peer
421 needs to be remade at each batch.  nntpsend (which uses innxmit)
422 cannot make use of multiple connections to a single peer site.
423 However, nntpsend automatically find which sites need feeding by
424 looking in
425 .IR pathoutgoing ,
426 whereas the administrator needs to arrange to invoke innduct
427 separately for each peer.
428 .TP
429 .B innxmit
430 is the actual NNTP feeder program used by nntpsend.
431 .SH EXIT STATUS
432 .TP
433 .B 0
434 An instance of innduct is already running for this
435 .I feedfile
436 and
437 .B -q
438 was specified.
439 .TP
440 .B 4
441 The feed has been dropped by innd, and we (or previous innducts) have
442 successfully offered all the old articles to the peer site.  Our work
443 is done.
444 .TP
445 .B 8
446 innduct was invoked with bad options or command line arguments.  The
447 error message will be printed to stderr, and also (if any options or
448 arguments were passed at all) to syslog with severity
449 .BR crit .
450 .TP
451 .B 12
452 Things are going wrong, hopefully shortage of memory, system file
453 table entries; disk IO problems; disk full; etc.  The specifics of the
454 error will be logged to syslog with severity
455 .B err
456 (if syslog is working!)
457 .TP
458 .B 16
459 Things are going badly wrong in an unexpected way: system calls which
460 are not expected to fail are doing so, or the protocol for
461 communicating with innd is being violated, or some such.  Details will
462 be logged with severity
463 .B crit
464 (if syslog is working!)
465 .TP
466 .BR 24 - 27
467 These exit statuses are used by children forked by innduct to
468 communicate to the parent.  You should not see them.  If you do, it is
469 a bug.
470 .SH FILES
471 innduct dances a somewhat complicated dance with innd to make sure
472 that everything goes smoothly and that there are no races.  (See the
473 two ascii-art diagrams in innduct.c for details of the protocol.)  Do
474 not mess with the feedfile and other associated files, other than as
475 explained here:
476 .IX Header "FILES"
477 .IP \fIpathrun\fR
478 .IX Item "default directory"
479 Default current working directory for innduct, and also default
480 grandparent directory for the command line socket.
481 .IP \fIpathoutgoing\fR/\fIsite\fR
482 .IX Item "default feedfile"
483 Default
484 .IR feedfile .
485 .IP \fIfeedfile\fR
486 .IX Item feedfile
487 Main feed file as specified in
488 .IR newsfeeds (5).
489 This and other batchfiles used by innduct contains lines each of which
490 is of the form
491 \&    \fItoken\fR \fImessageid\fR
492 where \fItoken\fR is the inn storage API token.  Such lines can be
493 written by \fBTf,Wnm\fR in a \fInewsfeeds\fR(5) entry.  During
494 processing, innduct overwrites lines in the batch files which
495 correspond to articles it has processed: each such line is replaced
496 with one containing only spaces.  Only innd should create
497 .IR feedfile ,
498 and only innduct should remove it.
499 .IP \fIfeedfile\fR_lock
500 .IX Item "lock file"
501 Lockfile, preventing multiple innduct invocations for the same
502 feed.  A process holds this lock after it has opened the lockfile,
503 made an fcntl F_SETLK call, and then checked with stat and fstat that
504 the file it now has open and has locked still has the name
505 \fIfeedfile\fR_lock.  (Only) the lockholder may delete the lockfile.
506 For your convenience, after the lockfile is locked,
507 .IR innfeed 's
508 pid, the
509 .IR site ,
510 .IR feedfile
511 and
512 .IR fqdn
513 are all written to the lockfile.  NB that stale lockfiles may contain
514 stale data so this information should not be relied on other than for
515 troubleshooting.
516 .IP \fIfeedfile\fR_flushing
517 .IX Item "flushing file"
518 Batch file: the main feedfile is renamed to this filename by innduct
519 before it asks inn to flush the feed.  Only innduct should create,
520 modify or remove this file.
521 .IP \fIfeedfile\fR_defer
522 .IX Item "flushing file"
523 Batch file containing details of articles whose transmission has very
524 recently been deferred at the request of the recipient site.  Created,
525 written, read and removed (only) by innduct.
526 .IP \fIfeedfile\fR_backlog.\fItime_t\fR.\fIinum\fR
527 .IX Item "backlog file"
528 Batch file containing details of articles whose transmission has less
529 recently been deferred at the request of the recipient site.  Created
530 by innduct, and will also be read, updated and removed by innduct.
531 However you (the administrator) may also safely remove backlog files.
532 .IP \fIfeedfile\fR_backlog\fIsomething\fR
533 .IX Item "manual backlog file"
534 Batch file manually provided by the administrator.  The file should be
535 complete and ready to process at the time it is renamed or hardlinked
536 to this name.  innduct will then automatically find and read and
537 process it (including blanking out entries for processed articles) and
538 eventually remove it.  \fIsomething\fR may not contain \fB#\fR \fB~\fR
539 or \fB/\fR.
540 .IP
541 Be sure to have finished writing the file before you rename it to
542 match the pattern \fIfeedfile\fR\fB_backlog\fR*, as otherwise innduct
543 may find and process the file, and even think it has finished it,
544 before you have written the complete file.  You may also safely remove
545 backlog files.
546 .IP \fIpathrun\fR\fB/innduct/\fB\fIsite\fR
547 .IX Item "control command line socket"
548 Default AF_UNIX listening socket for the control command line.  See
549 CONTROLLING INNDUCT, above.
550 .IP \fIfeedfile\fR_dump
551 .IX Item "debug dump file"
552 On request via a control connection innduct dumps a summary of its
553 state to this text file.  This is mostly useful for debugging.
554 .IP /etc/news/inn.conf
555 .IX Item inn.conf
556 Used for
557 .IR pathoutgoing
558 (to compute default
559 .IR feedfile
560 and associated paths),
561 .IR pathrun
562 (to compute default
563 .IR PATHRUN
564 and hence effective default
565 .IR CLI-DIR
566 and
567 .IR CLI-PATH ),
568 for finding how to communicate with innd, and also for
569 .IR sourceaddress
570 and/or
571 .IR sourceaddress6 .
572 .SH HISTORY
573 Written by Ian Jackson <ijackson@chiark.greenend.org.uk>
574 .SH "SEE ALSO"
575 inn.conf(5),
576 innd(8),
577 newsfeeds(5)