rtorrent icon indicating copy to clipboard operation
rtorrent copied to clipboard

Option for limit log file size?

Open alaneuler opened this issue 5 years ago • 6 comments

I run rtorrent as a daemon, and connect via flood front-end. However, the log file for xmlrpc xmlrpc.log grows to rather large (Gigabytes even). How can I set a limit to it? My rtorrent version: Rakshasa's BitTorrent client version 0.9.7.

method.insert = cfg.basedir,  private|const|string, (cat,"~/Downloads/")
method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"download/")
method.insert = cfg.logs,     private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile,  private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.session,  private|const|string, (cat,(cfg.basedir),".session/")
method.insert = cfg.watch,    private|const|string, (cat,(cfg.basedir),"watch/")

execute.throw = sh, -c, (cat,\
    "mkdir -p \"",(cfg.download),"\" ",\
    "\"",(cfg.logs),"\" ",\
    "\"",(cfg.session),"\" ",\
    "\"",(cfg.watch),"/load\" ",\
    "\"",(cfg.watch),"/start\" ")

session.path.set = (cat, (cfg.session))
directory.default.set = (cat, (cfg.download))
log.execute = (cat, (cfg.logs), "execute.log")
log.xmlrpc = (cat, (cfg.logs), "xmlrpc.log")
execute.nothrow = sh, -c, (cat, "echo >",\
    (session.path), "rtorrent.pid", " ",(system.pid))

bind = 0.0.0.0
network.port_range.set = 53552-53552
network.port_random.set = no

dht.mode.set = disable
protocol.pex.set = no
trackers.use_udp.set = no

throttle.global_down.max_rate.set_kb = 0
throttle.global_up.max_rate.set_kb = 0
throttle.max_uploads.global.set = 1000
throttle.max_downloads.global.set = 1000
throttle.max_uploads.set = 100
throttle.max_downloads.set = 100
throttle.min_peers.normal.set = 100
throttle.max_peers.normal.set = 400
throttle.min_peers.seed.set = -1
throttle.max_peers.seed.set = -1
trackers.numwant.set = 100
protocol.encryption.set = allow_incoming,try_outgoing,enable_retry

network.max_open_files.set = 600
network.max_open_sockets.set = 999
network.http.max_open.set = 99
network.receive_buffer.size.set =  4M
network.send_buffer.size.set = 12M
pieces.preload.type.set = 2

encoding.add = utf8
system.umask.set = 0027
system.cwd.set = (directory.default)
network.http.dns_cache_timeout.set = 25
schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M))
pieces.memory.max.set = 2048M
network.xmlrpc.size_limit.set = 2M

system.daemon.set = true
network.scgi.open_local = (cat,(session.path),rpc.socket)
execute.nothrow = chmod,770,(cat,(session.path),rpc.socket)

print = (cat, "Logging to ", (cfg.logfile))
log.open_file = "log", (cfg.logfile)
log.add_output = "info", "log"

ratio.enable=
ratio.min.set = 10000
ratio.max.set = 30000
ratio.upload.set = 20M

Startup command: /usr/bin/rtorrent -n -o import=/home/alaneuler/Downloads/.pt/rtorrent.rc Linux kernel version: 5.1.7-arch1-1-ARCH

alaneuler avatar Jun 09 '19 06:06 alaneuler

You should add a scheduled event that rotates the logs, e.g. copy or delete the log file then reopen it.

However, looks like I never got around to implementing log_close_output.

rakshasa avatar Jun 09 '19 14:06 rakshasa

I know logrotate can do the job. If rtorrent never closes the log file, it seems that this workaround doesn't work?

alaneuler avatar Jun 09 '19 15:06 alaneuler

https://rtorrent-docs.readthedocs.io/en/latest/use-cases.html#log-rotation

There are various bugs in vanilla rtorrent that prevent this from fully working there, like xmlrpc log handle leaks on reopen, and the inability to close / reopen some log types. Fixes for all this are available.

pyroscope avatar Jun 10 '19 16:06 pyroscope

copyrotate in logrotated can work around the issues somewhat, but unfortunately includes a chance of missing messages (see the man page for more details).

kannibalox avatar Jun 11 '19 00:06 kannibalox

Here's @pyroscope 's patch that works well with simple logrotate.

chros73 avatar Jun 13 '19 21:06 chros73

I don't know if this is still an issue for anyone, but I'm planning to restart rtorrent each night which will ensure that rtorrent's logs are properly closed (and rotated). Then, use something like tmpwatch or tmpreaper to delete based on it's age. I realize that this might not be a practical work around for some, but my restart at least is to ensure VPN connectivity and forwarded port rotation.

moozhub avatar May 11 '23 16:05 moozhub