Howto: testing 0.6 using deluged + webui (headless *nix)

General support for problems installing or using Deluge
oshiri
Member
Member
Posts: 40
Joined: Thu Nov 29, 2007 10:34 am

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by oshiri »

Thanks cvig.
That does it.

The new script:

Code: Select all

#!/bin/sh
# created by mambang
# Headless deluge startup script

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DELUGE="/usr/bin/deluge"
DELUGE_OPTIONS="-u web"
USER="Your User"    #Please change

DELUGEDAEMON="/usr/bin/deluged"
DESC1="Deluge Daemon"
DESC2="WebUi"
NAME1="deluged"
NAME2="Deluge webserver"

set -e


case "$1" in
  start)
        echo -n "Starting $DESC1 : "
        start-stop-daemon -c $USER --start --background --quiet --exec $DELUGEDAEMON
        echo "$NAME1"
        sleep 2
        echo -n "Starting $DESC2 : "
        start-stop-daemon -c $USER --start --background --quiet --exec $DELUGE -- ${DELUGE_OPTIONS}
        echo "$NAME2"
        ;;
  stop)
        echo -n "Stopping $DESC1 : "
        PIDDELUGE=`ps ax |grep deluged |sed -n 1p |awk '{print $1}'`
        kill $PIDDELUGE
        echo "$NAME1."
        echo -n "Stopping $DESC2 : "
        PIDWEB=`ps ax |grep deluge |sed -n 2p |awk '{print $1}'`
        kill $PIDWEB
        echo "$NAME2."
        ;;
  *)
        N=deluge-daemon
        echo "Usage: $N {start|stop|restart}" >&2

        exit 1
        ;;
esac

exit 0
arbrandes
New User
New User
Posts: 3
Joined: Tue Apr 29, 2008 8:50 pm

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by arbrandes »

Here's my take on it, using the somewhat standard /etc/init.d/*-daemon, /etc/default/*-daemon combo. I managed to get it so /var/run/*.pid files are generated, so no need for grepping and awking to stop the daemon.

You have to specify the user in /etc/default/deluge-daemon. You can also choose whether or not the daemon will run on startup.

/etc/default/deluge-daemon

Code: Select all

# Configuration for /etc/init.d/deluge-daemon

# The init.d script will only run if this variable non-empty.
DELUGED_USER="deluge"

# Should we run at startup?
RUN_AT_STARTUP="YES"
/etc/init.d/deluge-daemon

Code: Select all

#!/bin/sh
### BEGIN INIT INFO
# Provides:          deluge-daemon
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Should-Start:      $network
# Should-Stop:       $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Daemonized version of deluge and webui.
# Description:       Starts the deluge daemon with the user specified in
#                    /etc/default/deluge-daemon.
### END INIT INFO

# Author: Adolfo R. Brandes <arbrandes@gmail.com>

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Deluge Daemon"
NAME1="deluged"
NAME2="deluge"
DAEMON1=/usr/bin/deluged
DAEMON1_ARGS="-d"
DAEMON2=/usr/bin/deluge
DAEMON2_ARGS="-u web"
PIDFILE1=/var/run/$NAME1.pid
PIDFILE2=/var/run/$NAME2.pid
PKGNAME=deluge-daemon
SCRIPTNAME=/etc/init.d/$PKGNAME

# Exit if the package is not installed
[ -x "$DAEMON1" -a -x "$DAEMON2" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

if [ -z "$RUN_AT_STARTUP" -o "$RUN_AT_STARTUP" != "YES" ]
then
	log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
	exit 0
fi

if [ -z "$DELUGED_USER" ]
then
    log_warning_msg "Not starting $PKGNAME, DELUGED_USER not set in /etc/default/$PKGNAME."
    exit 0
fi

#
# Function that starts the daemon/service
#
do_start()
{
	# Return
	#   0 if daemon has been started
	#   1 if daemon was already running
	#   2 if daemon could not be started
	start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --exec $DAEMON1 \
		--chuid $DELUGED_USER --user $DELUGED_USER --test > /dev/null
	RETVAL1="$?"
	start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --exec $DAEMON2 \
		--chuid $DELUGED_USER --user $DELUGED_USER --test > /dev/null
	RETVAL2="$?"
	[ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 1

	start-stop-daemon --start --background --quiet --pidfile $PIDFILE1 --make-pidfile --exec $DAEMON1 \
		--chuid $DELUGED_USER --user $DELUGED_USER -- $DAEMON1_ARGS
	RETVAL1="$?"
        sleep 2
	start-stop-daemon --start --background --quiet --pidfile $PIDFILE2 --make-pidfile --exec $DAEMON2 \
		--chuid $DELUGED_USER --user $DELUGED_USER -- $DAEMON2_ARGS
	RETVAL2="$?"
	[ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] || return 2
}

#
# Function that stops the daemon/service
#
do_stop()
{
	# Return
	#   0 if daemon has been stopped
	#   1 if daemon was already stopped
	#   2 if daemon could not be stopped
	#   other if a failure occurred
	
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE2
	RETVAL2="$?"
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $DELUGED_USER --pidfile $PIDFILE1
	RETVAL1="$?"
	[ "$RETVAL1" = "2" -o "$RETVAL2" = "2" ] && return 2

	rm -f $PIDFILE1 $PIDFILE2

	[ "$RETVAL1" = "0" -a "$RETVAL2" = "0" ] && return 0 || return 1
}


case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME1"
	do_start
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME1"
	do_stop
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  restart|force-reload)
	log_daemon_msg "Restarting $DESC" "$NAME1"
	do_stop
	case "$?" in
	  0|1)
		do_start
		case "$?" in
			0) log_end_msg 0 ;;
			1) log_end_msg 1 ;; # Old process is still running
			*) log_end_msg 1 ;; # Failed to start
		esac
		;;
	  *)
	  	# Failed to stop
		log_end_msg 1
		;;
	esac
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
	exit 3
	;;
esac

:
Nameless
Member
Member
Posts: 16
Joined: Thu Mar 13, 2008 6:52 pm

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by Nameless »

I am trying to run deluge 0.6, but I get an error:

Code: Select all

--Deluge Error--
IOError : unsupported XML-RPC protocol
path : /connect
file : /usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/xmlrpclib.py in __init__, line 1413

--Input--
<Storage {'other_uri': 'http://localhost:52014', 'uri': 'other', 'submit': 'Connect'}>

--Versions--
WebUi : rev.<unknown:bzr-branch?>Python : 2.5.1 (r251:54863, Mar  7 2008, 04:10:12) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)]
dbus:0.82.0

--Traceback--
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/webui/lib/webpy022/webapi.py", line 304, in wsgifunc
    result = func()
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/webui/lib/webpy022/request.py", line 131, in <lambda>
    func = lambda: handle(inp, fvars)
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/webui/lib/webpy022/request.py", line 61, in handle
    return tocall(*([x and urllib.unquote(x) for x in args] + fna))
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/webui/pages.py", line 306, in POST
    utils.daemon_connect(uri)
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/webui/utils.py", line 245, in daemon_connect
    sclient.set_core_uri(uri)
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/client.py", line 257, in set_core_uri
    return self.core.set_core_uri(uri)
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/client.py", line 134, in set_core_uri
    self.get_rpc_core()
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/ui/client.py", line 143, in get_rpc_core
    self.rpc_core = xmlrpclib.ServerProxy(self._uri, allow_none=True)
  File "/usr/lib/python2.5/site-packages/deluge-0.6.0.0-py2.5-linux-i686.egg/deluge/xmlrpclib.py", line 1414, in __init__
    raise IOError, "unsupported XML-RPC protocol"
I use

Code: Select all

$ deluged -d -p 52104
$ deluge -u web
to run it. The port 52104 is open in my router.
mvoncken
Developer
Developer
Posts: 225
Joined: Mon Sep 03, 2007 9:38 pm

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by mvoncken »

[quote="Nameless"]I am trying to run deluge 0.6, but I get an error:

Code: Select all

--Deluge Error--
IOError : unsupported XML-RPC protocol
path : /connect
I fixed the crash on an invalid daemon.
you still have to connect manually to the other port in webui.
dev: webui, core, labels | irc:vonck7 |
hokum

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by hokum »

Please help me - how to enable logging in deluge-daemon script?
mvoncken
Developer
Developer
Posts: 225
Joined: Mon Sep 03, 2007 9:38 pm

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by mvoncken »

hokum wrote:Please help me - how to enable logging in deluge-daemon script?
http://dev.deluge-torrent.org/wiki/Faq# ... gtoconsole

Code: Select all

$ deluged -h
Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  Port daemon will listen on
  -d, --do-not-daemonize
                        Do not daemonize
  -c CONFIG, --config=CONFIG
                        Set the config location
  -l LOGFILE, --logfile=LOGFILE
                        Set the logfile location

dev: webui, core, labels | irc:vonck7 |
vzgromozdun

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by vzgromozdun »

Hi All,

I'm triyng to run deluged rc4 at startup of my Gentoo as non-root user. But seems like deluged can't change current user correctly.
Please see below my startup script and error message:

Part of script:
=============

start-stop-daemon -S --chuid alex --name deluged --pidfile /var/run/deluged.pid --make-pidfile --exec /usr/bin/deluged

Error message:
=============
Traceback (most recent call last):
File "/usr/bin/deluged", line 8, in <module>
load_entry_point('deluge==0.9.04', 'console_scripts', 'deluged')()
File "/usr/lib/python2.5/site-packages/deluge/main.py", line 122, in start_daemon
config_dir = deluge.common.get_default_config_dir()
File "/usr/lib/python2.5/site-packages/deluge/common.py", line 112, in get_default_config_dir
return xdg.BaseDirectory.save_config_path("deluge")
File "/usr/lib/python2.5/site-packages/xdg/BaseDirectory.py", line 59, in save_config_path
os.makedirs(path, 0700)
File "/usr/lib/python2.5/os.py", line 164, in makedirs
makedirs(head, mode)
File "/usr/lib/python2.5/os.py", line 171, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/root/.config'

==================== end of error message ==============

It seems like xdg.BaseDirectory.save_config_path("deluged"); returns config directory for old user.

Is anybody solve this problem?

Many thanks,
Dmitry
unityofsaints

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by unityofsaints »

mvoncken wrote:
hokum wrote:Please help me - how to enable logging in deluge-daemon script?
http://dev.deluge-torrent.org/wiki/Faq# ... gtoconsole

Code: Select all

$ deluged -h
Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -p PORT, --port=PORT  Port daemon will listen on
  -d, --do-not-daemonize
                        Do not daemonize
  -c CONFIG, --config=CONFIG
                        Set the config location
  -l LOGFILE, --logfile=LOGFILE
                        Set the logfile location


I think what he means is logging in the user mentioned in arbrandes' script so that it will not come up "permission denied" when you boot your system. I'm trying to get the script running and have the same problem, can anyone shed light on this?

Separate question: does the user that starts deluged have to have ownership of the folder where torrents are started using webui?

Thanks!
mvoncken
Developer
Developer
Posts: 225
Joined: Mon Sep 03, 2007 9:38 pm

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by mvoncken »

unityofsaints wrote: Separate question: does the user that starts deluged have to have ownership of the folder where torrents are started using webui?
Yes
dev: webui, core, labels | irc:vonck7 |
xternal

Re: Howto: testing 0.6 using deluged + webui (headless *nix)

Post by xternal »

Hey, thanks for the script guys. Great help
Just a quick question. Im running this on my server, and i ssh into my box from a windows machine. I use X to forward other programs. Is there a way, that once this program is up and running at startup, i can ssh into the box at anytime and forward the current session to my machine, without starting a new one.

Thanks
Post Reply