root/trunk/sources/transmission/README.daemon

Revision 7678, 17.9 kB (checked in by oleo, 2 years ago)

transmission: 4839->4868 - NEWS added to help

Line 
1 README.daemon
2
3 CGI interface to daemon is for managing and preview of the daemon state.
4 There is also torrent_watchdog script for automatic torrent
5 queue processing and mail notification.
6
7 Features
8
9 * batch multiprocessing (eg. 10 torrents simultaneously with nice priority)
10 * automatic seeding when torrent finishes (configurable)
11 * configurable ports
12 * WWW interface transmission.cgi can be public (no password) as
13    there is no delete provided.
14 * Accelerator keys (ALT-Shift-key) for CGI interface. See help for underlined keys.
15 * Per torrent and cumulative status
16 * start/stop/push/bypass and other commands available in WWW interface
17 * lightweight - low memory footprint
18 * tracker scrape info. Suggest best seed torrent from target dir.
19 * watchdog for auto restart/queue processing with cron
20 * syslog watchdog events
21 * mail notify when torrent finishes
22 * no state database required. Directory tree is database (slow, but fail-safe)
23 * stable and portable. Developed on Asus WL-500g Deluxe with OpenWrt Kamikaze firmware
24
25 Workflow
26
27 For queue torrent file processing there should exist tree directories:
28 source - User should copy .torrent files here
29 work   - Used for torrent processing
30 target - Place where finished torrents are put
31
32 Typical file flow is source -> work -> target For every torrent file from
33 source, directory with the same name is created. Then torrent file is moved
34 into this directory and transmissiond is run in background and constantly
35 supervised with transmission_watchdog. The only way for moving finished
36 active torrent into target dir is with Watchdog and not with Push.
37
38 CGI interface to daemon after each command lists all torrents in database.
39 This time consuming can be interrupted at any time by giving next command
40 or pressing stop button in WWW browser. This can be done for all commands
41 except URL, Note and Rename as the action on torrent is taken during
42 listing. This means that listing should not be interrupted until torrent is
43 listed. In general there is no problem of interrupting listing at any
44 point. This will not invalidate database which is file system alone.
45
46 Fetch command is useful only for fetching torrent files without passkey as
47 there is no possibility to pass cookies to server. Use with care. Proper
48 fetch would be "download in browser and then upload to server".
49 This can only be done by browser plugin.
50
51 Troubles with tracker communication can be seen in syslog file.
52 transmission_watchdog moves torrent to Suspended queue if Error: is
53 reported by tracker.
54
55 Before running transmission user should carefully inspect variables in
56 transmission.conf and create SOURCE, WORK, and TARGET directories
57
58 transmission_watchdog cares for queue processing and should be run every
59 30 minutes with cron. /opt/etc/crontab entry should look like:
60
61 # m  h dom mon dow user command
62 */30 *    * * *   admin nice transmission_watchdog
63
64 For graphing to work properly, gnuplot and syslog is required. As log can
65 accumulate it is recommended that logrotate is used for flushing old logs.
66 /opt/etc/logrotate.conf recommended config is:
67 compress
68
69 /opt/var/log/messages {
70         size 1024k
71         weekly
72         rotate 9
73         postrotate
74                 killall -HUP syslogd
75         endscript
76 }
77
78 include /opt/etc/logrotate.d
79
80 For syslog on Asus - Oleg firmware it is recommended that
81 /opt/etc/init.d/S05syslogd is created with the following content:
82
83 #!/bin/sh
84 #
85 # Startup script for syslogd
86 #
87 # Stop myself if running
88 if [ -n "`pidof syslogd`" ]; then
89     /usr/bin/killall syslogd 2>/dev/null
90 fi
91 # remove old syslog.log
92 rm /tmp/syslog.log
93 # add symlink so log is available at old location (e.g. for webinterface)
94 ln -s /opt/var/log/messages /tmp/syslog.log
95 /sbin/syslogd -m 0 -O /opt/var/log/messages -S -l 7
96
97 To disable rate control set upload/download limit to -1 in transmission.conf
98 Ratecontrol counts only good transferred packets. Handshaking and other
99 non-data transfer does not count. This means that there are some packets
100 in transfer that are not affected by ratecontrol ant that UPLOAD_SPEED should
101 be set to lower value than max upload line capability.
102
103 HOME variable is used for daemon to find its .transmission directory where
104 cache data for each torrent is stored for fast resume. Proper restore
105 requires that system time is functioning as file mtime is checked. Assure
106 that time sync is retrieved with ntp or RTC.
107
108 Visit http://transmission.m0k.org/forum/viewtopic.php?p=4871#4871 for more
109 info.
110
111 Troubleshooting daemon & CGI interface
112
113 Very helpful command for debugging shell script is "sh -x
114 /opt/share/www/cgi-bin/transmission.cgi" This will print out every line and
115 its content.
116
117 I suggest to install procps package and then use
118 /opt/bin/ps axf to see output like this:
119
120 9179 ? SNs 0:01 transmissiond -p 65534 -w 600 -u -1 -d -1 -i ..
121 9180 ? SN  0:00  \_ transmissiond -p 65534 -w 600 -u -1 -d -1 -i  ...
122 9181 ? SN  0:00      \_ transmissiond -p 65534 -w 600 -u -1 -d -1 -i ..
123
124
125
126 Master thread in above example has PID=9179 Sending "kill -USR1 9197" must
127 write .status files. This should also be done by CGI.
128
129 There is also -USR2 signal which writes active torrents into syslog. But
130 syslog must be running also for getting cumulative statistics!
131
132 .status file is sourced. Filenames should not contain non ASCII characters
133 and quote. Spaces and characters like [](). are allowed in torrent filenames.
134 Note that NO spaces is allowed for directories ${SOURCE}, ${WORK} and ${TARGET}.
135
136 When one presses "Update" button signal -USR1 is sent to daemon and after a
137 second of waiting for it, all active .status files are sourced and printed.
138
139 Problems with .status could be that transmisisond is not receiving USR1 signal.
140 This may be due to invalid path to PIDFILE or something like that.
141 Pressing Update sends signal to daemon, waits one second and reads
142 .status files in active torrent directories. Take attention to syslog daemon.
143
144 "torrent" package conflict is intentional.
145 If you want transfer graph log then gnuplot must be installed.
146
147 For using www browser on router itself package lynx or elink is recommended.
148 lynx http://localhost:8008/cgi-bin/transmission.cgi
149
150 Known bugs:
151 * There is a problem with fork and pthreads in uclibc 0.9.19
152   See http://www.busybox.net/lists/uclibc/2003-March/005825.html
153   This affect only users of Oleg firmware on Asus routers with
154   http://ipkg.nslu2-linux.org/feeds/optware/wl500g/cross/stable/
155   package feed. Users are instructed to switch to
156   http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/
157   which uses newer uClibc 0.9.28 and NLPT or change transmission_watchdog
158   daemon startup code to
159
160   nohup transmissiond -v 1 -p ${LISTENING_PORT} \
161         -w ${WATCHDOG} \
162         -u ${UPLOAD_SPEED} \
163         -d ${DOWNLOAD_SPEED} \
164         -i ${PIDFILE}   ${ACTIVE} 2> /dev/null &
165
166   which will spawn daemon in foreground mode and trash error messages.
167
168   See http://wl500g.info/showpost.php?p=34579&postcount=68 how to upgrade
169   to alternative "Oleg"  package feed.
170
171 * With upgrade to r2220 and later one must take care, that there will
172 not be unfinished torrents otherwise Transmission will report "hash FAILED".
173 Erase such torrents and start over. Same instruction goes to problem with
174 high loads (over 20) causing system freeze. In such cases is recommended
175 to erase cache files with rm -rf ${WORK}/.transmission
176
177
178 OpenWRT and Xwrt(OpenWRT for mere mortals) notes:
179
180    With whiterussian OpenWRT and Xwrt is fully operational.
181    I recommend to create disk partitions (opt, swap and data) with
182    some linux system as the OpenWRT lacks some fdisk and
183    busybox (mkswap, swapon, swapof) packages which can be found on
184    rc5-backports.
185    
186    Install the following USB and ext2/3 packages:
187     - kmod-usb-core - 2.4.30-brcm-5 - Kernel Support for USB
188     - kmod-usb-storage - 2.4.30-brcm-5 - Kernel modules for USB storage support
189     - kmod-usb2 - 2.4.30-brcm-5 - Kernel driver for USB2 controllers
190     - kmod-ext2 - 2.4.30-brcm-5 - Kernel modules for EXT2 filesystem support
191     - kmod-ext3 - 2.4.30-brcm-5 - Kernel modules for EXT3 filesystem support
192
193 But after that you will be able to mount disk partitions.
194 See http://www.nslu2-linux.org/wiki/FAQ/Optware-uClibcBuild
195 for aditional X-wrt notes.
196
197 Follow dd-wrt guidelines for installing Optware packages to X-wrt
198 http://www.dd-wrt.com/wiki/index.php/Optware
199
200    logrotate is not necessary as the OpenWRT cron and log daemon (circular Local LOG)
201    can be used. Recommended size for /var/log/messages is 100kB. If using
202    circular buffer then logread should be used to read its data.
203    If using logread then transmission.cgi must be updated at some lines
204    where ${SYSLOG} occurs:
205
206    SPEED=`logread | tail  | sed  -n '/transmissiond/s/.*\dl \([0-9.]\{1,\}\) ul \([0-9.]\{1,\}\).*/DOWNLOAD="\1";UPLOAD="\2"/p' | tail -1`
207
208 #if [ ! -r ${SYSLOG} ]; then
209 #  echo "<p>${SYSLOG} not readable. Properly configure syslogd at "
210 #  echo "system startup.</p>"
211 #  return                                                                                                                                           
212 #fi
213 echo "<pre>"
214 logread |sed  -n -e "/transmissiond/{s/.*: \([0-9]\{1,10\}\) [0-9]\{1,\} dl \([0-9.]\{1,\}\) ul \([0-9.]\{1,\}\) ld \([0-9.]\{1,\}\)/\1 \2 -\3 \4/;t
215 echo "</pre>"
216
217
218    
219    /opt/etc/transmission.conf changes:
220    SYSLOG=/var/log/messages
221
222    Using OpenWRT cron daemon for watchdog purposes
223    Create the following /etc/crontab contents:
224    SHELL=/bin/sh
225    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin
226    MAILTO=""
227    HOME=/
228    # ---------- ---------- Default is Empty ---------- ---------- #
229    # m h dom mon dow user  command
230    30 *    * * *   root nice transmission_watchdog
231
232    then run "crontab /etc/crontab"
233    and edit with crontab -e root
234  
235 FAQ
236
237 1. Why wont the daemon start downloading after rebooting ? I need to push
238 it to suspend and then again to make it work ? It will restart after reboot
239 if you properly configured cron to run transmisison_watchdog periodicly.
240 For manual restart use Watchdog button.
241
242 2. How do i make it download 5 torrents at the same time ? Can this be done
243 ? Sure it can. Use Push button. You can also queue torrents, manual
244 administer and get some transfer graph.
245
246 3. Is it possible to output a chart with no_UTC time (X-axis) ?
247 Just set TIMEZONE_OFFSET=seconds in transmission.conf
248
249 4. I just installed transmission package, pushed some torrent and it looks
250 working. But when I press Update button, I get this result: ".status not
251 found for <torrent_path>" Problems with .status could be that transmisisond
252 is not receiving USR1 signal. This may be due to invalid path to PIDFILE or
253 something like that. Pressing Update sends signal to daemon, waits one
254 second and reads .status files in active torrent directories. Take
255 attention to syslog daemon.
256
257 5. Do I need "torrent" ipkg installed too?
258 No. torrent package conflict is intentional.
259
260 6. I am getting some errors
261
262 cat: /opt/var/run/transmission.pid: No such file or directory
263 /opt/share/www/cgi-bin/transmission.cgi: kill: 624: Usage: kill [-s sigspec
264 | -signum | -sigspec] [pid | job]... or kill -l [exitstatus]getting some
265 errors cat: /opt/var/run/transmission.pid: No such file or directory
266 /opt/share/www/cgi-bin/transmission.cgi: kill: 624: Usage: kill [-s sigspec
267 | -signum | -sigspec] [pid | job]... or kill -l [exitstatus]
268
269   This means that Transmisison daemon is not running. Use Watchdog button
270  to start in manually.
271
272 7. Tried manually pressing watchdog for nothing. Im still having that text
273  under the buttons on the script page :
274
275  /opt/share/www/cgi-bin/transmission.cgi: kill: 624: (249) - No such process .
276
277  It looks like daemon died for some reason. Take a look into syslog
278  messages. The recommended way for running is using "Oleg" feed and not
279  default "wl500g".
280
281 8. What directories need to be created by default?
282 mkdir /tmp/harddisk/torrent
283 mkdir /tmp/harddisk/torrent/source
284 mkdir /tmp/harddisk/torrent/work
285 mkdir /tmp/harddisk/torrent/target
286 chmod a+rw /tmp/harddisk/torrent
287 chmod a+rw /tmp/harddisk/torrent/source
288 chmod a+rw /tmp/harddisk/torrent/target
289 chmod a+rw /tmp/harddisk/torrent/work
290
291 9. My daemon dies frequently. 512 MB swap is recommended on 32MB routers.
292
293
294 10. How do I password protect transmission.cgi script? Use appropriate web
295  server and its protection. busybox_http uses IP access and password
296  protection with httpd.conf
297
298 11. Can I set some cap on UPLOAD_SPEED or is this thing totally bugged ? If
299  bugged any workaround ? This bug is a hard thing. Anyway ratecontrol is
300  somehow useless as it limits only good packets and not the whole
301  transport. I recommend to use some QOS router capabilities. Personally I
302  use another OpenWRT router.
303
304 12. Does this daemon allow active port transfer? I mean do i have to open
305  ports manually thru iptables to point the active port to router or
306  similar? I believe program who use active connections boosts the transfers
307  in seeding or receiving, allowing more connetions.
308
309  You need to open incoming TCP port on router (65534). It also recommended
310  to allow ping responses (ICMP protocol). To check connectivity with
311  telneting to your listening port
312  
313  telnet  your.outside.router.ip 65534
314  Connected to your.outside.router.ip
315  Escape character is '^]'.
316  help me
317  Nice try...
318  Connection closed by foreign host.
319
320  You should get "Nice try..." response.
321
322 13. How can I interpret load average and uptime values in graph and CGI? We
323    can assume (by looking at procps top) that CPU is mostly idling and that
324    most uninterruptable state is waiting for some I/O access, eg waiting
325    for disk access. So load average over 1 means that external USB disk is
326    doing operations for more processes and it cannot handle without waiting
327    for disk. In such cases I recommend to lower the number of active
328    torrents. Mostly downloading gives much burden.
329
330 14. Is there an easy way to open ports for transmission? Yes. If your
331     router soupports traversal using NAT-PMP or UPnP IGD services just
332     uncomment NAT_TRAVERSAL line in /opt/etc/transmission.conf
333
334 15. I'm trying to get the graph to work for transmission the cron is
335    running and everything is logging to syslog but the only thing that is
336    showing up is load. Edit : I got it working but is there a way to have
337    it form a line like load does.
338
339    I do not recommend anything else than spikes for Transmission graphing.
340    SysLog rotation should be tailored in such way that it acumulates approx
341    one week. Then spikes will show in high density and you will see if
342    there was any interruption without hearbeat. Lines like load could be
343    changed in transmission.cgi but then you will loose interval display.
344    Maybe linespoints is middleway?
345
346 16. I am getting "Could not open ....nfo in /tmp/harddisk/torrent/work/...
347   (0, -2147483640)" This bug is harmless. It tries to check nonexistent
348   file at startup. libtransmission developer should eventually add empty
349   file creation or skip this check.
350
351 17. I also implemented transmission and I am very much excited. But shame
352    on me, I am not able to purge these damned completed torrents. I tried
353    everything.
354
355    This is the feature of the Transmission. You cannot remove torrents with
356    WWW interface!
357    Use simple file removal like:
358         cd /tmp/harddisk/torrent/target
359         ls -lt */*.torrent
360         rm -rf My.Torrent.directory
361
362    Or just use simple samba share and delete it under Windows explorer. For
363    active and suspended torrents use: Push them with the 'push' button from
364    Seeding state to Suspend. Then select the torrent en click Remove. After
365    that you can Purge them into oblivion.
366
367    There is also an option add FORCE_REMOVE="YES" to transmission.conf and
368    this will enable removing of DONE non-seeding torrents. Use with caution
369    when exposing CGI page to internet.
370
371 18. My links: "source" "work" and "target" are not valid. This depends on
372  your http daemon. If you are using busybox_httpd then there is no autodir
373  feature and links are preaty useless. If thttpd is used the you can create
374  symlinks to directories and enable follow symlinks in config. Same goes to
375  other servers. Anyway this links are not regarded as a feature but rather
376  useless convenience.
377
378 19. Well, it does not work at all When i choose push on a torrent i just
379 get the infamous "/opt/share/www/cgi-bin/transmission.cgi: kill: 9: (335) -
380 No such process" error .. It is assumed that transmssiond is started
381 through transmission_watchdog when you are using transmission.cgi. If
382 transmissiond is stopped/paused/not running then you get informational
383 message like (kill, not running, ...) This is not a problem if you know
384 what you are doing. You can administer torrents even faster if
385 transmissiond is not running. When finished with huge rearangements the you
386 can unpause and restart with watchdog.
387
388 transmission_watchdog is run every 30 minutes or so through cron process.
389 That's why there is no startup script for transmissiond. Although I've seen
390 that some people run transmission_watchdog at system startup, I do not
391 recommend such practice.
392
393 20. I am getting .status not found. I am getting Unable to find recent
394 transfer stats in syslog.
395
396 transmissiond wirks in nonblocking mode. This means that some stats in
397 .status file are written when transmissiond gets time to write them.
398 Sometimes transmissiond is too busy to write status on time and it misses
399 status wtiteout that CGI fetches. This is harmless but confusing sometimes
400 as it shows different sum of transfer stats. Just press Update again and
401 stats should be updated correctly.
402
403 21. How can I install the new version ?  Cos by doing ipkg update it will
404 erase my configuration.
405 Transmisison will not erase your configuration during upgrade!
406 It will always ask you what to do with /opt/etc/transmission.conf
407 Use ipkg update and ipkg upgrade for package upgrade!
408
409 22. The interface PAUSE button is missinterpreted. If I click on the PAUSE button, I have to click again on the same button to resume the transfers. Took me about 1 hour to find out this.
410 Think of Pause button as Pause on tape recorder. It Stops/Starts activity of the transmission daemon. And yes, it is design problem of the static header that prevents Resume/Pause button.
411
412 23. How to get the busybox httpd work with it ?
413    Instead of busybox httpd  you could use thttpd.
414
415 oleo
416
417
Note: See TracBrowser for help on using the browser.