Wednesday, 22 October 2008

Running Azureus (Vuze) as a windows service revisited

This is a follow-up to my 2006 post. It's a shame I'm not using Windows any more and I can't figure this out for OS X, but the old post continues to get hits, so I thought I would neaten things up a bit!

I haven't completely tested this system with more recent versions of Azureus/Vuze, but all the files seem to be much the same, so I'm guessing it will be OK. Please leave any comments with news to the contrary.

As before, I have taken much of my information from other places, but I feel I've put it together in an easier to follow manner. In particular, the bulk of ideas came from the azureus wiki

Step 1: Install Azureus and enable Headless operation

  1. Download the executable installer from sourceforge
  2. Ensure that the installation directory contains the file Azureus2.jar
  3. Download the files log4j.jar and commons-cli.jar from here and place into the Azureus directory. This will allow command-line (headless) operation.
  4. To run, use command java -jar Azureus2-XXX.jar --ui=console
Your Azureus directory should look like this

Step 2: Install plugins

  1. Run Azureus in regular mode. NB: To configure the options for these plugins (and any other general settings such as download directories, you need to be in regular GUI mode)

  2. Install the HTML WebUI plugin. Configure the settings for the plugin such as the port number, username and password

  3. At the same time, I installed the Speed Scheduler

Step 3: Test the setup so far

  1. Exit from GUI

  2. Run: java -jar Azureus2.jar --ui=console

  3. Go to 127.0.0.1:6886, enter username and password and you should see the WebUI as below.

  4. Exit from the command line (Ctrl-C), try to refresh the HTML (it shouldn't work).

Step 4: Install the service

Thanks to info here and here.
  1. Need to install the programs instsrv.exe and srvany.exe from the Win2K resource kit. I put it in C:\Program Files\reskit

  2. Run the following command: C:\Program Files\reskit\INSTSRV.EXE Azureus C:\Program Files\reskit\SRVANY.EXE. This creates a windows service in the "services" control panel applet, and the appropriate registry entry.

4.1 Edit registry.

  1. Go to the new registry key at HKEYLOCALMACHINE\system\CurrentControl\Set\Services\Azureus

  2. Create a new key "Parameters" and go there

  3. Create the following String Values (NB: string values do not contain quotes):

  4. Application: Java

  5. AppParameters: "-jar -Xrs Azureus2.jar --ui=console" (NB the -Xrs switch is to stop the the console from shutting down when logged off - not sure if I understand why, but the wiki article says "You'll then find that whenever someone logs out of the computer, Azureus will stop. That's because the Java VM is trapping some signals like WM_ENDSESSION, and exits gracefully. You can tell Java to ignore it, with the switch -Xrs, as documented by Sun)

  6. AppDirectory: "c:\program files\azureus" (or whatever is appropriate)

4.1 Edit control panel stuff

  1. Go to control panel, administrative tools, services (see image above)

  2. Find azureus, double click for properties
  • In the General tab, probably want startup type as automatic
  • In the Log On tab - use "this account" and set up your details. If these don't match, then what you set up when using the GUI won't match to the details when running as a service.
  • Tell the service to "start" then test as above

Step 5: Usage

I also created a couple of shortcuts to enable quick starting and stopping of the service (eg when the download is slowing your net connection):
  • "Start downloads": %windir%\system32\net.exe start azureus

  • "Stop downloads": %windir%\system32\net.exe stop azureus
I make sure these shortcuts are somewhere Launchy (or your app launcher of choice) can get to them to make turning azureus on and off a breeze.