[SOLVED] execute plugin causes deluge hang

Suggest, post, or discuss plugins for Deluge
Post Reply
voltaicsca
New User
New User
Posts: 8
Joined: Sat Dec 17, 2011 3:50 am

[SOLVED] execute plugin causes deluge hang

Post by voltaicsca »

I am executing the attached script when deluge finishes a torrent, but while the script is executing, deluge behaves as though the daemon is not running.
All clients report it as offline (web, GTK, and console), however, I can run top and see that it is running, and is in a valid state.
once the script finishes, everything goes back to normal, except that if a torrent completed while the script was running, the newly completed torrent does NOT get the script executed on it.

I have run the script with the same command line options that deluge gives it, and the problems described above do not happen.

Code: Select all

#!/bin/bash

torrentid="$1"
torrentname="$2"
torrentpath="$3"

localpath="/home/deluge/"
remotepath="/home/remoteuser/media/"

scpresume="rsync --partial --progress --inplace --rsh=ssh"

retries=0
result=1

torrentfullpath="$torrentpath/$torrentname"
torrentdest=${torrentfullpath#$localpath}
torrentdest="${remotepath}${torrentdest}"
torrentdest=`dirname "${torrentdest}"`

echo "log for $torrentname" >> /home/deluge/lastxfer.txt

until (( retries>10 || result==0 ))
do
        #wait a little longer each time.
        sleep $((retries*10))m
        (( retries += 1 ))
        echo "try #${retries}" >> /home/deluge/lastxfer.txt
        eval $scpresume -r "\"$torrentfullpath\"" username@destinationhost:"${torrentdest}/"
        result=$?
done

if (( result != 0 ))
        then
        echo "scp never completed sucesssfully" >> /home/deluge/lastxfer.txt
fi
is there a way with the execute plugin to run the script, and then "let go"? for example

Code: Select all

/path/myscript.sh &
I suspect that the execute plugin is blocking deluge from doing certain things while a script runs.
Last edited by johnnyg on Fri Mar 02, 2012 2:39 am, edited 2 times in total.
Reason: problem is now actually solved
voltaicsca
New User
New User
Posts: 8
Joined: Sat Dec 17, 2011 3:50 am

Re: execute plugin causes deluge hang

Post by voltaicsca »

well, it may not be the most elegant solution, but I just made a wrapper script to call the actual script:

wrapper.sh

Code: Select all

/home/deluge/complete.sh $1 $2 $3 &
So, the wrapper script exits immediately, while the complete.sh keeps running in the background.

If there's another way to do this, I'd love to hear it.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: [solved, sort of] execute plugin causes deluge hang

Post by johnnyg »

Running your script in the background is probably the simplest solution.

The problem is that the execute plugin waits for the process to complete so that it can report scripts whose exit code is non-zero.
This can be seen on line 120: http://git.deluge-torrent.org/deluge/tr ... table#n120
If you compiled deluge from source you could comment out lines 120 & 121 of that file to prevent it from blocking.

The better, long term solution would be to not wait on the process (or at least have an option to not wait on it) but still have it print the return code (and possibly stderr if it's non-zero).
Feel free to create a ticket for this.
johnnyg
Top Bloke
Top Bloke
Posts: 1522
Joined: Sun Oct 28, 2007 4:00 am
Location: Sydney, Australia

Re: [solved, sort of] execute plugin causes deluge hang

Post by johnnyg »

Just as an update to this thread (seeing no one created a ticket),
I've made it so that deluge no longer waits on an execute command.
I've also added stdout & stderr logging when the command fails (to make debugging easier).

Both of these commits (b002951 & be75d50) will be in the next release (1.3.4).
Post Reply