Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 256026 - net-p2p/rtorrent using app-misc/dtach as daemonizer
Summary: net-p2p/rtorrent using app-misc/dtach as daemonizer
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement with 3 votes (vote)
Assignee: Jason Zaman
URL:
Whiteboard:
Keywords: NeedPatch
Depends on:
Blocks:
 
Reported: 2009-01-22 17:37 UTC by Nils Larsson
Modified: 2018-06-19 15:19 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ebuild with || ( screen dtach ) dep (rtorrent-0.8.4-r1.ebuild.patch,427 bytes, patch)
2009-02-15 03:09 UTC, runoverheads
Details | Diff
/etc/conf.d/rtorrentd with DAEMONIZER var (rtorrentd.conf,129 bytes, text/plain)
2009-02-15 03:11 UTC, runoverheads
Details
/etc/inint.d/rtorrentd can start 'screen' or 'dtach' (rtorrentd.init,1.01 KB, text/plain)
2009-02-15 03:12 UTC, runoverheads
Details
diff between my version and the one in portage (rtorrent-0.8.4-r2.ebuild.diff,2.67 KB, patch)
2009-02-22 22:30 UTC, Stanislav Cymbalov
Details | Diff
init script for version with dtach (rtorrentd.init.dtach,1.23 KB, text/plain)
2009-02-22 22:31 UTC, Stanislav Cymbalov
Details
init script for version with screen (rtorrentd.init.screen,1.09 KB, text/plain)
2009-02-22 22:31 UTC, Stanislav Cymbalov
Details
conf file for version with dtach (rtorrentd.conf.dtach,318 bytes, text/plain)
2009-02-22 22:32 UTC, Stanislav Cymbalov
Details
conf file for version with screen (rtorrentd.conf.screen,258 bytes, text/plain)
2009-02-22 22:33 UTC, Stanislav Cymbalov
Details
script that simplify using version with dtach (rtorrent-attach,179 bytes, text/plain)
2009-02-22 22:34 UTC, Stanislav Cymbalov
Details
rtorrent-0.8.6-r2.tar.gz (rtorrent-0.8.6-r2.tar.gz,4.72 KB, application/octet-stream)
2011-02-02 17:17 UTC, Alex Barker
Details
proposed patch (rtorrentd.init.diff,618 bytes, patch)
2013-12-21 11:16 UTC, adr
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nils Larsson 2009-01-22 17:37:43 UTC
net-p2p/rtorrent-0.8.4 pulls in app-misc/screen if USE="daemon" is set. As rtorrent doesnt have any "daemon mode", screen is used to daemonize it. dtach, with detaching as its only funtionality(and its 55 kB vs. screens 831 kB source size) would be a more appropriate alternative.

IMHO, a simple,
$ dtach -A /tmp/dtach-rtorrent.socket /usr/bin/rtorrent
and
$ dtach -a /tmp/dtach-rtorrent.socket 
to attach is easier then fiddling around with screen.


Reproducible: Always

Steps to Reproduce:
Comment 1 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-01-22 17:52:38 UTC
I'm not familar with dtach. Please provide a diff of the init scripts that work for either screen or dtach and I will consider them. Keep in mind, the screen users will have the same complaints about dtach as you do for screen. As for why the screen implementation, upstream provided hints on that. http://libtorrent.rakshasa.no/wiki/RTorrentCommonTasks#tkt-changes-hdr

Thanks.
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-01-22 18:01:29 UTC
(In reply to comment #0)

> IMHO, a simple,
> $ dtach -A /tmp/dtach-rtorrent.socket /usr/bin/rtorrent
> and
> $ dtach -a /tmp/dtach-rtorrent.socket 
> to attach is easier then fiddling around with screen.

btw, that is just an opinion. "screen -dr" is pretty easy too ;)
Comment 3 Nils Larsson 2009-01-27 09:26:00 UTC
> btw, that is just an opinion. "screen -dr" is pretty easy too ;)

Yeah, hence the _IMHO_, heh.

The Gentoo Wiki rtorrent article talks about dtach,
http://en.gentoo-wiki.com/wiki/Rtorrent
Comment 4 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-02-04 04:49:58 UTC
I'm going to mark this as "NeedPatch"

I envision a conf.d file with some env var to specify if you want dtach or screen then carry on from there (either screen or dtach should work). ofc, that means that *both* apps will have to be dependencies...or some clever elog stating that dtach is an option. I would like to leave screen as the default. Personal choice..sorry. 

Patches welcome.
Comment 5 runoverheads 2009-02-15 03:03:16 UTC
> Patches welcome.

Very simple patch. See attachmests. 'screen' is default, but we can use 'dtach'.
Comment 6 runoverheads 2009-02-15 03:09:09 UTC
Created attachment 182084 [details, diff]
ebuild with || ( screen dtach ) dep
Comment 7 runoverheads 2009-02-15 03:11:12 UTC
Created attachment 182086 [details]
/etc/conf.d/rtorrentd with DAEMONIZER var
Comment 8 runoverheads 2009-02-15 03:12:21 UTC
Created attachment 182087 [details]
/etc/inint.d/rtorrentd can start 'screen' or 'dtach'
Comment 9 runoverheads 2009-02-15 03:13:00 UTC
Comment on attachment 182084 [details, diff]
ebuild with || ( screen dtach ) dep

><?xml version="1.0"?><html><head/><body><pre>--- /usr/portage/net-p2p/rtorrent/rtorrent-0.8.4-r1.ebuild	2009-02-13 01:06:59.000000000 +0300
>+++ /usr/local/portage/net-p2p/rtorrent/rtorrent-0.8.4-r1.ebuild	2009-02-15 06:03:44.000000000 +0300
>@@ -19,7 +19,7 @@
> 	sys-libs/ncurses
> 	xmlrpc? ( dev-libs/xmlrpc-c )"
> RDEPEND="${COMMON_DEPEND}
>-	daemon? ( app-misc/screen )"
>+	daemon? ( || ( app-misc/screen app-misc/dtach ) )"
> DEPEND="${COMMON_DEPEND}
> 	dev-util/pkgconfig"
></pre></body></html>
Comment 10 runoverheads 2009-02-15 03:23:37 UTC
I have set alias for fast reattaching rtorrent:
alias rt="tput smkx;dtach -a /tmp/rtorrent.dtach -e "^T";tput rmkx"

use 'rt' to attache and Ctrl+^T to detache it back
Comment 11 Stanislav Cymbalov 2009-02-22 22:26:30 UTC
Hi!

I mix the two versions (with app-misc/dtach and with app-misc/screen) into one ebuild.
I also corrected a few bugs and added some features.
Here is a list of changes:

1) USE-flag "daemon" is replaced by 2 flags: "screen" and "dtach". Now the user can select which program to use.
The previous solution using the variable "DAEMONIZER" allows to switch between app-misc/screen and app-misc/dtach while the dependence || (app-misc/screen app-misc/dtach) does not guarantee that both are installed.

2) Considering the bug # 241172, I rewrote the line with start-stop-daemon call and found that when TERM=xterm the arrow keys do not work after attaching to the rtorrent. I encountered this when using app-misc/dtach, but I think that with app-misc/screen will be the same problem. So, I replaced the "xterm" to "linux", which solved the problem for me. Now value of variable TERM may be configured.

3) Since termination of rtorrent can take a long time, I added a delay between sending messages SIGINT and SIGKILL. This can be configured in configuration file.

4) I also added to the version with app-misc/dtach a simple script "rtorrent-atach", which allows to connect to rtorrent in one command. It also changed the way disconnection - used a combination of C-q, which excludes the possibility of inadvertent termination of the program.

5) Some other minor fixes - see attached files.
Comment 12 Stanislav Cymbalov 2009-02-22 22:30:14 UTC
Created attachment 182826 [details, diff]
diff between my version and the one in portage
Comment 13 Stanislav Cymbalov 2009-02-22 22:31:37 UTC
Created attachment 182828 [details]
init script for version with dtach
Comment 14 Stanislav Cymbalov 2009-02-22 22:31:57 UTC
Created attachment 182830 [details]
init script for version with screen
Comment 15 Stanislav Cymbalov 2009-02-22 22:32:58 UTC
Created attachment 182832 [details]
conf file for version with dtach
Comment 16 Stanislav Cymbalov 2009-02-22 22:33:18 UTC
Created attachment 182833 [details]
conf file for version with screen
Comment 17 Stanislav Cymbalov 2009-02-22 22:34:11 UTC
Created attachment 182835 [details]
script that simplify using version with dtach
Comment 18 Scott 2009-12-06 20:23:27 UTC
Considering that start-stop-daemon will fail if the program is already running, IMHO, it would be better to encapsulate the dtach or screen call in a new executable, such as /usr/bin/rtorrentd, so that the user can be running dtach or screen, and still start rtorrentd. Unless I am mistaken, and you can change this behavior in start-stop-daemon.
Comment 19 Cameron Tacklind 2010-03-13 03:44:54 UTC
(In reply to comment #18)
> Considering that start-stop-daemon will fail if the program is already running,
> IMHO, it would be better to encapsulate the dtach or screen call in a new
> executable, such as /usr/bin/rtorrentd, so that the user can be running dtach
> or screen, and still start rtorrentd. Unless I am mistaken, and you can change
> this behavior in start-stop-daemon.
> 

I ran into this issue with the screen method, as I always start a screen session when I log in. start-stop-daemon noticed my screen was already running and wouldn't start. This doesn't cause a problem at boot since you aren't logged in when it starts, but would if you restarted it. This is what I changed in the init.d: (changing the --exec to a --startas and adding a new --exec that is rtorrent)

--exec /usr/bin/rtorrent \
--startas /usr/bin/dtach -- -n /tmp/rtorrentd.sock /usr/bin/rtorrent

Oh, and this includes my dtach method. -n creates a new socked and starts it detached, which was the other issue I ran into.
Comment 20 Alex Barker 2011-02-02 17:17:13 UTC
Created attachment 261363 [details]
rtorrent-0.8.6-r2.tar.gz 

I got tired of dealing with screen and running the current version of rtorrent as root so I updated what you guys did and created an ebuild that does a better job of running as a daemon by using app-misc/dtach.
Comment 21 adr 2013-12-21 11:14:26 UTC
IMHO, the proposed patches are way out of sync with the .init and .conf files for Screen. The patches don't even work (anymore) with a current installation. The Screen .init file is very basic. I think that's fine. We can all add our fun stuff and customizations later, and bring the good tips to the Gentoo rTorrent wiki [ http://wiki.gentoo.org/wiki/RTorrent ].
Comment 22 adr 2013-12-21 11:16:45 UTC
Created attachment 365814 [details, diff]
proposed patch

All what's needed for using dtach.
Comment 23 Stephen Shkardoon 2018-06-17 18:56:43 UTC
As rtorrent supports daemon mode from 0.9.7, I think it'd be better to just make the ebuild use that rather than add support for dtach. It's not implemented in the ebuild yet due to some bugs, but could be in the future.
Comment 24 Jason Zaman gentoo-dev 2018-06-19 15:19:00 UTC
its native daemon mode seems the way to go instead of dtach