[SOLVED] Strange pidfile behaviour

General support for problems installing or using Deluge
Post Reply
Spadge
Seeder
Seeder
Posts: 111
Joined: Sat Dec 13, 2008 4:17 pm

[SOLVED] Strange pidfile behaviour

Post by Spadge »

Deluge has been doing this a while, but I never thought to mention it before ...

Whenever I start deluged it creates a pidfile thanks to the -P option. The weirdness is that it insists on putting the listening port (for GUI connection) in there with the PID.

Code: Select all

root@tobermory# cat /path/to/deluged.pid 
71373;58846
So when I call on a restart or stop from the rc.d script it tries to kill the process and whatever is running with PID 58846.

Deluge is v1.3.3-dev from GIT, OS is FreeBSD8.2
Last edited by Spadge on Fri Aug 05, 2011 8:45 pm, edited 1 time in total.
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Strange pidfile behaviour

Post by Cas »

Could you supply the whole line that you are using to run deluged as the pidfile output is as expected when testing on Ubuntu.

The code to write the pidfile is below and there is nothing that could suggest that the port would be added to that file. You could test this in a python console to see what value is returned by FreeBSD.

Code: Select all

open(options.pidfile, "wb").write("%s\n" % os.getpid())
Spadge
Seeder
Seeder
Posts: 111
Joined: Sat Dec 13, 2008 4:17 pm

Re: Strange pidfile behaviour

Post by Spadge »

Code: Select all

Python 2.7.2 (default, Jul 25 2011, 12:42:51) 
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> open(options.pidfile, "wb").write("%s\n" % os.getpid())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'options' is not defined
>>> 
The startup line in my rc.d script is as follows:

spadge@tobermory$ pg deluge
DLMonkey 71373 0.0 2.3 85844 73464 ?? I 11:35AM 0:29.15 /usr/local/bin/python /usr/local/bin/deluged -c /home/DLMonkey/.config/deluge/ -L info -l /home/DLMonkey/.config/deluge/deluged.log -P /home/DLMonkey/.config/deluge/deluged.pid

Although this is derived from some convoluted variable-heavy script:

Code: Select all

name="deluged"
log="/home/DLMonkey/.config/deluge/${name}.log"
loglevel="info"
pidfile="/home/DLMonkey/.config/deluge/${name}.pid"
cfg_dir="/home/DLMonkey/.config/deluge/"
deluged_user="DLMonkey"

.../...

su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -L ${loglevel} -l ${log} -P ${pidfile} > /dev/null"
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Strange pidfile behaviour

Post by Cas »

Sorry didn't clarify, to test that piece of code you need to import os and substitute the variable. However here is a oneliner that can show what value os.getpid is returning:

Code: Select all

python -c "import os; print os.getpid()"
Spadge
Seeder
Seeder
Posts: 111
Joined: Sat Dec 13, 2008 4:17 pm

Re: Strange pidfile behaviour

Post by Spadge »

Code: Select all

spadge@tobermory$ python -c "import os; print os.getpid()"
72634
Which is probably what you were hoping it would return :)
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Strange pidfile behaviour

Post by Cas »

It is because you are putting the deluged.pid into the config dir and deluged creates its own pid file which includes the port.

Simply rename or change the location of the pidfile you are creating.
Spadge
Seeder
Seeder
Posts: 111
Joined: Sat Dec 13, 2008 4:17 pm

Re: Strange pidfile behaviour

Post by Spadge »

Well I never ;)

Thanks for the tip!

You should probably consider renaming the self-created pidfile to something that isn't .pid you know.
Spadge
Seeder
Seeder
Posts: 111
Joined: Sat Dec 13, 2008 4:17 pm

Re: Strange pidfile behaviour

Post by Spadge »

I've created a deluge dir in /var/run and chowned it to the user who runs deluged, pointed the pidfile create option to it and would just like to report that everything is now fine.

Thanks again :)
Post Reply