[BitTorrent] How to control a background job

Nick Johnson arachnid at notdot.net
Wed Jan 12 16:53:39 EST 2005

Bill Cox wrote:

>I could use some advice on the best way to control a background job.
>The interface to the job has two goals: first, to allow for text based
>control; second to allow a simple interface that nicer GUI could drive
>(which I don't intend to write).  What's the best way to do it?
>The job I'd like to conntrol is btslave, a BT client that typically will
>run in the background.  It's primary job is helping your normal BT
>client download faster (as a slave repeater).  It needs to be told when
>to join a torrent, or it wont know that you're downloading.  Right now,
>I kill the job, and restart it with the torrent file name on the command
>Several options come to mind:
>I could just parse user commands from the command line, like ftp.
>However, as a demon running in the background, I don't know how to get
>access to stdin and stdout.  I could also use a config file, and send a
>SIGHUP signal to btslave to have it re-read it.  That's not very user
>friendly.  I could support a telnet port, and get access to a command
>line interface that way.  I could support a ssh connection directly to
>btslave.  Is this hard?  Portable?  I could provide an http interface,
>the way swat does.  That's a lot of work.  I could support a command
>line interface, but enable one copy of btslave to control another over a
>TCP connection.
>There are other permutations.  How would you guys do it?
Assuming this is on *nix, I would have the daemon process create a 
(datagram?) unix socket in an agreed location (/var/run or /tmp, 
typically), and issue commands to it over that. The executable could 
either daemonise itself or send instructions to an already daemonised 
process over the socket, depending on the command line parameters 
provided. The existence of the socket can also be used to prevent more 
than one daemon starting, if that's desired.

-Nick Johnson

Yahoo! Groups Links

<*> To visit your group on the web, go to:

<*> To unsubscribe from this group, send an email to:
    BitTorrent-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

More information about the BitTorrent mailing list