You are not logged in.

#1 2009-07-30 23:46:58

DePingus
Member
From: Miami, Fl
Registered: 2008-09-07
Posts: 44

java app as daemon

Hi guys,

I'm having a bit of problem getting x360mediaserve to run as a daemon. Actually, I'm having problems getting it to stop it after its started. I made a script in /etc/rc.d that points to the x360mediaserve's starting script. If I do a ps -A it shows the daemon running as "java" instead of "x360ms". Also, when I start the daemon from the command line, all the daemon's output goes to my command line instead of into outer space.

Any ideas?

/etc/rc.d/x360ms

#!/bin/bash

PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/jre/bin
DESC="x360mediaserve"
NAME=x360ms
DAEMON=/usr/bin/x360ms/start
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Starting pms server..."
    $DAEMON &
    if [ $? -gt 0 ]; then
      stat_fail
     else
      add_daemon $NAME
      pidof $NAME > $PIDFILE
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping pms server..."
    if [ -a $PIDFILE ]; then
      PID='cat $PIDFILE'
      kill $PID > /dev/null
      if [ $? -gt 0 ]; then
        stat_fail
      else
        rm $PIDFILE
        rm_daemon $NAME
        stat_done
      fi
    else
      pkill $NAME
      if [ $? -gt 0 ]; then
        stat_fail
      else
        stat_done
      fi
    fi
    ;;
  restart|force-reload)
    $0 stop
    sleep 1
    $0 start
    ;;
esac
exit 0

/usr/bin/x360ms/start

java -cp x360mediaserve.jar:lib/cyberlink/clink170.jar:lib/cyberlink/cmgatejava120.jar:lib/jetty/commons-logging.jar:lib/entagged/entagged-audioformats-0.15.jar:lib/jetty/servlet-api-2.5-6.0.1.jar:lib/jetty/jetty-6.0.1.jar:lib/jetty/jetty-util-6.0.1.jar:lib/xerces/xercesImpl.jar:lib/xerces/xml-apis.jar:lib/cyberlink/clinkwrap.jar Run $1

Offline

#2 2009-07-31 03:46:51

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: java app as daemon

I'm no scripting expert, but shouldn't you throw the terminal output into a file or /dev/null to get it to stop outputting to stdout?

Haven't got any idea about your other problem though.


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#3 2009-07-31 04:28:38

DePingus
Member
From: Miami, Fl
Registered: 2008-09-07
Posts: 44

Re: java app as daemon

Thanks. I think you're right, I forgot to send the output to /dev/null. When I do that I don't get any daemon output BUT now the daemon doesn't finish loading. It doesn't fail, it just stays stuck on BUSY the whole time.

I also noticed when the daemon is running (without sending the output to null) that "start" was there too along side "java". Still no "x360ms" tho. I'm thinking that it has something to do with nested scripts.

This headless media server is turning into a real pain in the caboose...

edit:
I just tried playstation media  server (pms) and i'm having the same problem daemonizing it. It starts (as long as I dont send the output to /dev/null) but I can't stop it unless I ps -A and kill java.

Last edited by DePingus (2009-07-31 05:50:31)

Offline

#4 2009-07-31 21:09:14

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: java app as daemon

Hello DePingus!

What's the exact output from term if you try to stop it ?

Offline

Board footer

Powered by FluxBB