title
Products            Buy            Support Forum            Professional            About            Codec Central
 

Attempting to get Asset UPnP Running as a Service - help! (plus a couple of requests)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Photon

    • Sep 2014
    • 4

    Attempting to get Asset UPnP Running as a Service - help! (plus a couple of requests)

    Hi all,

    I just bought AssetUPnP linux, and am attempting to get it running under Ubuntu server. I can get the server to work perfectly just running from the command line, but would like to basically get it running as a service.

    Your installation advice (adding the call to rc.d) would basically end up with the server running as root, which given its webserver nature (see later request) I am somewhat unkeen on. I started attempting to get the server to run as an upstart job under Ubuntu. So far I have made reasonable progress, but it would seem that the server itself does NOT like to run in the upstart environment, possibly due to its fondness of outputting to stdout, which is a bit of a no-no as far as linux daemons go. The app starts, then immediately exits with error 255 - could you clarify what this error means?

    I am tempted to go old school and attempt to get it running using an init.d script, but I'm not entirely sure this will give much better results until I understand the above error. For what its worth, my upstart script is as follows:

    Code:
    description "Asset UPnP server"
    
    start on (local-filesystems and net-device-up IFACE!=lo)
    stop on stopping network-services
    
    respawn
    respawn limit 10 5
    
    setuid music
    
    exec /usr/bin/asset/AssetUPnP
    which when run, results in the following in syslog:

    Code:
    Sep 24 11:09:20 clanger kernel: [2917171.788955] init: asset-upnp main process (29653) terminated with status 255
    As a debug thing ubuntu suggest running the app along the following lines to test how the app will react to being run in an upstart environment :

    Code:
    user=music
    cmd=/usr/bin/asset/AssetUPnP
    su -c 'nohup env -i $cmd </dev/null >/dev/null 2>&1 &' $user
    Which also fails, hence my suspicion about the problems using stdout (although piping output to a logfile also similarly fails)

    Appart from support on this, I have a couple of future requests:

    It would really simplify matters if you gave a command line switch to daemonize, either single fork or double fork, however if this is not possible, I would strongly recommend replacing the stdout output with a logfile (again, ideally configurable as to location)

    It would also really be handy to be able to specify which IP address (interface) to bind to - my server is dual homed, with one interface peeking onto the greater internet, and as of the minute I am basically having to firewall it off. This could also cause issues I would imagine should the server not be able to bind its port on one of the interfaces for whatever reason.

    Thanks in advance,

    P.
  • Photon

    • Sep 2014
    • 4

    #2
    Re: Attempting to get Asset UPnP Running as a Service - help! (plus a couple of reque

    Heh...

    After making this post I did a little bit of fiddling, and it turns out its the user change that breaks it. If I remove the setuid from the Upstart config or the su-c 'blah' $user from the test script, it all works fine, so I was completely wrong about the output (although it would be nice for it to be logged somewhere still).

    So, that doesn't make a whole heap of sense - it runs fine if I just login as that user and run it, but attempting to change the user it executes as results in error 255 - any ideas?

    Comment

    • Spoon
      Administrator
      • Apr 2002
      • 44583

      #3
      Re: Attempting to get Asset UPnP Running as a Service - help! (plus a couple of reque

      Sorry no idea.
      Spoon
      www.dbpoweramp.com

      Comment

      • Photon

        • Sep 2014
        • 4

        #4
        Re: Attempting to get Asset UPnP Running as a Service - help! (plus a couple of reque

        Could you at least tell me what error code 255 means? Am I in the right place for support? - I was lead to understand that Asset UPnP was supported, being a paid product and all.

        Comment

        • Spoon
          Administrator
          • Apr 2002
          • 44583

          #5
          Re: Attempting to get Asset UPnP Running as a Service - help! (plus a couple of reque

          255 is the program exiting at some point with -1, only stderror will show what the error is. Have you tried redirecting std output? > /tmp/error.txt
          Spoon
          www.dbpoweramp.com

          Comment

          • PeterP
            Super Moderator
            • Jul 2011
            • 1471

            #6
            Re: Attempting to get Asset UPnP Running as a Service - help! (plus a couple of reque

            Thank you for your feedback.

            The request to allow binding Asset server to a specific IP on a multi-homed system has been noted.

            We are researching the error 255 issue - it looks like a generic failure reply from Asset, it does not say much about what happened.

            Comment

            • Photon

              • Sep 2014
              • 4

              #7
              Re: Attempting to get Asset UPnP Running as a Service - help! (plus a couple of reque

              Hi Spoon,

              Unfortunately there was no output - I did pipe it and ended up with an empty file unfortunately.

              Peter - thanks for that. It does appear to quit almost instantaneously - my current suspicion is that there is something about the environment of running it inside su -c that it really doesn't like.

              The good news is I managed to work around it, old school. The bad news is that they don't want to support System-V too much longer!

              My init.d script looks as follows (and this works, including running as the right user, ironically)

              Code:
              *!/bin/sh
              *** BEGIN INIT INFO
              * Provides:          asset-upnp
              * Required-Start:    $network $local_fs $remote_fs
              * Required-Stop::    $network $local_fs $remote_fs
              * Should-Start:      $all
              * Should-Stop:       $all
              * Default-Start:     2 3 4 5
              * Default-Stop:      0 1 6
              * Short-Description: Asset UPnP Media server
              *** END INIT INFO
              
              unset USER
              
              * PATH should only include /usr/* if it runs after the mountnfs.sh script
              PATH=/sbin:/usr/sbin:/bin:/usr/bin
              DESC="Asset UPnP (DLNA Compatible) Media Server"
              NAME=asset-upnp
              DAEMON=/usr/bin/asset/AssetUPnP
              PIDDIR=/var/run/$NAME
              PIDFILE=$PIDDIR/$NAME.pid
              SCRIPTNAME=/etc/init.d/$NAME
              DEFAULT=/etc/default/$NAME
              
              * Exit if the package is not installed
              [ -x $DAEMON ] || exit 0
              
              * Read configuration variable file if it is present
              [ -r $DEFAULT ] && . $DEFAULT
              
              * Load the VERBOSE setting and other rcS variables
              . /lib/init/vars.sh
              
              * Define LSB log_* functions.
              * Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
              . /lib/lsb/init-functions
              
              START_DAEMON="yes"
              
              * Do not start the daemon if NO_START is enabled in DEFAULT
              if [ "$START_DAEMON" != "yes" ] && [ "$1" != "stop" ]; then
                      log_warning_msg "$NAME: Not starting $DESC."
                      log_warning_msg "$NAME: Disabled in $DEFAULT."
                      exit 0
              fi
              
              * Run as `music' if USER is not specified or is `root'
              if [ -z $USER ]; then
                      USER=music
              fi
              
              * If no group is specified, use USER
              if [ -z $GROUP ]; then
                      GROUP=$USER
              fi
              
              DAEMON_ARGS=""
              
              *
              * 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
                      *touch $LOGFILE && chown $USER:$GROUP $LOGFILE || return 2
                      if [ ! -d $PIDDIR ]; then
                          mkdir $PIDDIR || return 2
                      fi
                      chown $USER:$GROUP $PIDDIR || return 2
              
                      start-stop-daemon --start --quiet --make-pidfile --background --pidfile $PIDFILE \
                              --chuid $USER:$GROUP --exec $DAEMON --test > /dev/null \
                              || return 1
                      start-stop-daemon --start --quiet --make-pidfile --background --pidfile $PIDFILE \
                              --chuid $USER:$GROUP --exec $DAEMON -- \
                              $DAEMON_ARGS \
                              || 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 --pidfile $PIDFILE --name $NAME
                      RETVAL="$?"
                      [ "$RETVAL" = 2 ] && return 2
                      * Wait for children to finish too if this is a daemon that forks
                      * and if the daemon is only ever run from this initscript.
                      start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
                      [ "$?" = 2 ] && return 2
                      * Many daemons don't delete their pidfiles when they exit.
                      rm -rf $PIDDIR
                      return "$RETVAL"
              }
              
              
              case "$1" in
                start)
                  [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
                  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" "$NAME"
                      do_stop
                      case "$?" in
                              0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                              2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
                      esac
                      ;;
                status)
                     status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
                     ;;
                restart|force-reload)
                      log_daemon_msg "Restarting $DESC" "$NAME"
                      do_stop
                      case "$?" in
                        0|1)
                              if [ "$1" = "force-reload" ]; then
                                      * Rescan the collection
                                      DAEMON_ARGS="$DAEMON_ARGS -R"
                              fi
                              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|status|restart|force-reload}" >&2
                      exit 3
                      ;;
              esac
              Fairly standard stuff (mainly based on the skeleton)

              The --make-pidfile and --background options for start-stop-deamon are less than desirable (an asset --deamonize option would be nice), but it certainly seems to work (note that Asset spawns multiple processes, however killing the first one appears to kill them all according to my testing)

              Thanks

              P.

              Comment

              Working...

              ]]>