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