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