daemon + script on complete = hang

Ask for help and report issues not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
zosky
Posts: 9
Joined: Thu Apr 08, 2010 9:15 pm

daemon + script on complete = hang

Post by zosky »

hi yall. lovin daemon but there seems to be a problem with the new feature to run script on complete...

here is the course of events (to reproduce the issue)...
  • a torrent completes... daemon triggers the complete-script ... it waits
  • the script tells daemon to move data to different locations (depending on the torrent's name & some rules)... it waits
    ... at this point the script is waiting for daemon ... daemon is waiting for the script ... :(
  • eventually the script times out (no response from daemon) & daemon starts up again
rather then waiting for the script to complete, shouldn't daemon spawn it as a separate process & continue its business ? this way it can focus on the other torrs (and still respond to the script :P). for the record - this is the perl script im using: myTV @hourly via cron

if im missing something, or doing something wrong, please let me know
thanks
~z
Longinus00
Posts: 137
Joined: Fri Aug 21, 2009 5:46 am

Re: daemon + script on complete = hang

Post by Longinus00 »

To work around this right now fork your script.
zosky
Posts: 9
Joined: Thu Apr 08, 2010 9:15 pm

Re: daemon + script on complete = hang

Post by zosky »

Longinus00, you are a pro! thanks
that a freakin easy work-around.
(kinda feel like a dip for not thinking of it myself)
  • on-complete calls man-in-the-middle
  • man-in-the-middle forks & dies
  • daemon picks up again
  • myTV tells daemon to move stuff
this should still be considered a bug ?
daemon should do the forking, right
lazybones
Posts: 220
Joined: Sun Jan 24, 2010 12:41 am

Re: daemon + script on complete = hang

Post by lazybones »

zosky wrote:Longinus00, you are a pro! thanks
that a freakin easy work-around.
(kinda feel like a dip for not thinking of it myself)
  • on-complete calls man-in-the-middle
  • man-in-the-middle forks & dies
  • daemon picks up again
  • myTV tells daemon to move stuff
this should still be considered a bug ?
daemon should do the forking, right

I believe they made the script call blocking so that if you needed to do something to a file that transmission may have open that you could do your thing without transmission changing the files... Thus leaving the option to simply put a control script in that forks and doesn't block..
Metallian
Posts: 2
Joined: Thu Oct 14, 2010 10:47 am

Re: daemon + script on complete = hang

Post by Metallian »

Hi,

I think i have the same problem
I'm trying to run transmission-remote from a script.
When i launch it from the command line, everything runs fine
But when it is run from the script-torrent-done-filename directive, i get a timeout (RPC ERROR)

What does "fork a script" mean ?
How am I supposed to do that ?

Sorry if the question is dumb
I'm new to Linux
Metallian
Posts: 2
Joined: Thu Oct 14, 2010 10:47 am

Re: daemon + script on complete = hang

Post by Metallian »

I finally found the answer
you need to place the command into () with the symbol & at the end to run it in another process

Here's an easy example script to autoremove a torrent on completion

# !/bin/bash
(/opt/bin/transmission-remote --torrent $TR_TORRENT_ID --stop &)
(/opt/bin/transmission-remote --torrent $TR_TORRENT_ID --remove &)
zosky
Posts: 9
Joined: Thu Apr 08, 2010 9:15 pm

Re: daemon + script on complete = hang

Post by zosky »

thats a bad bad example
you need to seed your completes (or prepare to get flamed :shock: )

anyway, if you want to fork a whole script... try this

Code: Select all

    { 
        <multiple lines> 
    } &
here's what im doing

Code: Select all

#!/bin/bash
{
  # set vars 
  # unrar code ...  
  # move data ...

  # email notification
	echo "<table><tr><td></td><td>FYI, a new DL is ready<td></tr>
	       <tr><td align=right>TORRENT:</td><td><b>$TR_TORRENT_NAME</b></td></tr>
	       <tr><td align=right>LOCATION:</td><td><b>$LOCATION</b></td></tr>
	       <tr><td align=right>SOURCE:</td><td><b>$TRACKER</b></td></tr>
	       <tr><td align=right>ID:</td><td><b>$TR_TORRENT_ID</b></td></tr>
	       <tr><td></td><td>~homeNAS</trable>" > $MSG
	mail -a 'Content-Type: text/html' -s "$SUBJECT" "$EMAIL" < $MSG 

  # txt msg notificaction
	EMAIL="<redacted>"
	SUBJECT="newDL"
	echo "DONE: $TR_TORRENT_NAME" > $MSG
	mail -s "$SUBJECT" "$EMAIL" < $MSG 
} &
Post Reply