Unix socket, scgi mounts and the rpc plugin

dsouvik215

Member
May 25, 2018
896
0
16
Are you using scgi_port or a unix-socket for communication with rtorrent?

If you are using unix-sockets i would be interested in how you got it running. configs, access rights ...
 

das329717

Member
May 25, 2018
928
0
16
he used the rpc plugin which doesn't require you to use a webserver at all


i can explain how to do a unix socket.

one thing you DO need to do is figure out a way to make sure the socket is removed on start up. if you start rtorrent with a boot script, then you need to add this mechanism to your boot script. I for one use cron for this, and i can show you my cron freebsd script (it won't work on linux)

but ANYWAYS

add this to .rtorrent.rc
Code:
scgi_local = /usr/home/rtorrent/.sock/scgi.socket
schedule = chmod,0,0,"execute=chmod,777,/usr/home/rtorrent/.sock/scgi.socket"

of cource you can change the ACTUAL location to anywhere you want

then wherever you have rtorrent installed, change the infomation in config.php to
Code:
$scgi_port = 0;
$scgi_host = "unix:///usr/home/wonslung/rtorrent/.sock/scgi.socket";

i use the cherokee webserver which makes setting an rpc mount with a unix socket simple but i would imagine it's pretty much the same for lighttpd.

for lighttpd the config is
Code:
scgi.server = (
“/RPC2″ => #RT_DIR
(”127.0.0.1″ =>
(
“socket” => “/usr/home/wonslung/rtorrent/.sock/scgi.socket”, # Socket specified in .rtorrentrc
“check-local” => “disable”,
“disable-time” => 0 # don’t disable scgi if connection fails
)))


for cherokee, it's just done via the wizard in cherokee-admin, by far the easiest method


one note, if you're going to change the subject, it's normally better to make a new thread.
 

dsouvik215

Member
May 25, 2018
896
0
16
Please feel free to split the post up and make a seperate topic out of it. My humble apologies.

-Is there something to be made different when using the rpc_plugin? Because it didn't work out of the box and i thought i need to setup a unix-socket first.

- Do i read this correct: I need to remove the socket before starting rtorrent so it can be recreated?
 

das329717

Member
May 25, 2018
928
0
16
the rpc plugin should work out of the box so long as you have php installed......the only thing required is setting up the port and mount.

you set the port in .rtorrent.rc and in the config.php for rutorrent's files, you set the rpc mount in rs.js

are you SURE you've installed the plugin rpc/


If rtorrent crashes, the socket doesn't delete. If the socket isn't gone, then it wont' start up. It's a design flaw probably. The simple solution to this is to have your startup script delete the socket. On freebsd i have a script that does the following:

Check disk space, if under x amount then->
Check if rtorrent is running
remove socket|start rtorrent

i put this in a cronjob for each user as @reboot and to check every 10 minutes
this is my script:
Code:
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/bin:/sbin
SERVICE='rtorrent'
FILE="/usr/home/$USER/rtorrent/.sock/scgi.socket"

df /usr/home/$USER| tail -1 | while read fs size used avail pcnt mount;
do
pcnt=$(echo ${pcnt} | cut -d'%' -f1 )
if [ ${pcnt} -ge 95 ]; then
echo "Running out of space \"${fs} (${pcnt}%)\" on ${HOSTNAME} as on $(date)"
exit 1
fi

if pgrep -u $USER $SERVICE > /dev/null
then
echo "$SERVICE service running, everything is fine"
else
rm -f ${FILE}
echo "$SERVICE is not running, starting $SERVICE"| screen -d -m -S seedbox $SERVICE
fi
done

in order to make this work on linux you'd have to change some stuff....i'm not sure abotu the diskspace section of the script at all...but the check if rtorrent is running section can be changed to something like
Code:
ps aux $SERVICE|grep -v|grep $SERVICEbut this is just a guess
 

das329717

Member
May 25, 2018
928
0
16
also, i didn't mean to jump in your shit about your question, it was more of a.....suggestion, splitting the topic was a good idea, shows you how much I know. =)
 

dsouvik215

Member
May 25, 2018
896
0
16
no offense taken. I do know the other side sooooo well.

Since my rtorrent didn't crash over 5-6 months since i last restarted it i will leave out the socket-check for now.
Also since i can't seem to find the error i recall my settings.

Scenario One:
.rtorrent.rc
Code:
scgi_local = /home/verwalter/rtorrent/.socket/rpc.socket
schedule = chmod,0,0,"execute=chmod,777,/home/verwalter/rtorrent/.socket/rpc.socket"
rutorrent config.php
Code:
$scgi_port = 0;
$scgi_host = "unix:///home/verwalter/rtorrent/.socket/rpc.socket";
Apache httpd.conf
Code:
SCGIMount /RPC2 127.0.0.1:5000
rs.js
Code:
XMLRPCMountPoint : "/RPC2",
rutorrent-directory
Code:
/var/www/rutorrent/plugins:
total 80K
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:05 autotools
drwx------ 2 www-data www-data 4,0K 2009-11-05 21:05 choose
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:06 cookies
drwx------ 4 www-data www-data 4,0K 2009-11-05 21:05 create
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:06 darkpal
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:05 datadir
drwx------ 4 www-data www-data 4,0K 2009-11-05 21:05 edit
drwx------ 2 www-data www-data 4,0K 2009-11-05 21:05 erasedata
drwx------ 4 www-data www-data 4,0K 2009-11-05 21:06 geoip
drwx------ 2 www-data www-data 4,0K 2009-11-05 21:05 _getdir
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:06 ratio
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:06 retrackers
drwx------ 2 www-data www-data 4,0K 2009-11-05 21:05 rpc
drwx------ 5 www-data www-data 4,0K 2009-11-05 21:05 rss
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:07 scheduler
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:07 search
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:07 seedingtime
drwx------ 3 www-data www-data 4,0K 2009-11-05 21:07 throttle
drwx------ 2 www-data www-data 4,0K 2009-11-05 21:05 tracklabels
drwx------ 5 www-data www-data 4,0K 2009-11-05 21:05 trafic

Result:
Code
http://myserver/rutorrenttells me to check my config files (Check $scgi_port and $scgi_host settings in config.php and scgi_port in rTorrent configuration file) and
Code:
http://myserver:rt-port/rtorrentonly shows (literally translated) "Display via a plugin" in the upper left corner


Scenario Two:
.rtorrent.rc
Code:
scgi_port = localhost:5000
rutorrent config.php
Code:
$scgi_port = 5000;
$scgi_host = "127.0.0.1";
Apache httpd.conf
Code:
SCGIMount /RPC2 127.0.0.1:5000
Result:
Code:
http://myserver/rutorrentkeeps trying to load the webinterface (Loading uTorrent WebUI in <Language> ...)


Conclusion:
Right now i think most likely it has something to do with the Apache-config, on secondary level maybe with access rights.
 

das329717

Member
May 25, 2018
928
0
16
its the apache config

if you use a unix socket you need to use a webserver which supports unix sockets. I think a patch exists for apache but as is mod_scgi doesn't support unix sockets
 

das329717

Member
May 25, 2018
928
0
16
the second setup should work....weird....i just woke up though, let me wake up some more and read it again
 

jith45

Member
May 25, 2018
960
0
16
I have the same problem as you have.
When I looked in apache access-log the last entry was "POST /rtorrent/getplugins.php HTTP/1.1".

I then removed the plugins I installed and now it's working.
 

dsouvik215

Member
May 25, 2018
896
0
16
@mons - you mean you are having apache+rutorrent with scgi-port setup now and it is only running if you remove any rutorrent plugins?

Currently i am on the same but with cherokee+rutorrent with scgi-port. Have not tried to add back any plugins since i finally had it working. I did make a fresh start back then so i can't say if the plugins would be working or not right now.
 

jith45

Member
May 25, 2018
960
0
16
Yeah, I'm running Apache + ruTorrent. It's a fresh install, and I just extracted 2 plugins to the plugins-folder.

When I removed them, ruTorrent started to work. It's only working with scgi-port. tried using sockets, but that didn't work.
 

jith45

Member
May 25, 2018
960
0
16
Thanks! That solved my problem.

Geoip was one of the 2 plugins I tried, and I didn't have pecl-geoip insalled.