8

I'm having a heck of a time getting a java program to launch properly in an init script using start-stop-daemon. I've written the init script and it seems to run but there's never a process afterward representing the running program.

Here's a snippet of my init script

#! /bin/sh
#
#

DAEMON="/usr/bin/java"
DAEMON_ARGS="-server -cp <bunch of RMI arguments and classpath stuff> -jar <absolute path>/myprog.jar"

PIDFILE="/var/run/myprog.pid"

case "$1" in
start)
    echo -n "Starting myprog"
    start-stop-daemon --start --pidfile "$PIDFILE" --chuid "myuser" --verbose --background --make-pidfile --startas "$DAEMON" -- $DAEMON_ARGS
    echo "."
;;

When I try to launch it via /etc/init.d I get the following:

/etc/init.d# /etc/init.d/myscript start

Starting myprogStarting /usr/bin/java...

Detatching to start /usr/bin/java...done.

.

Afterward, there is no java interpreter process running, executing myprog.jar

I've tried various combinations of --exec, --start with more or less the same results. If I could get some more visibility into what is going on, I'm sure I could figure this out but I'm not sure how to do even that.

Any suggestions?

(I'm running Angstrom on an embedded ARM platform so Java Service Wrapper isn't really an viable option, ie. I don't think its available for ARM)

I'm stuck so any advice would be really appreciated.

Thanks.

ColonelPackage
  • 501
  • 1
  • 5
  • 14

2 Answers2

14

Two things to try, first try removing --startas and use --exec instead like so:

start-stop-daemon --start --pidfile "$PIDFILE" --chuid "myuser" --verbose --background --make-pidfile --exec "$DAEMON" -- $DAEMON_ARGS

Second since you are using --background try specifying the --chdir option, if you don't the working directory ends up being /.

I ended up stumbling on your question trying to solve my issue which eventually was resolved by --chdir, I believe it will resolve yours as well.

Daniel Sokolowski
  • 10,545
  • 3
  • 61
  • 49
-4

you're looking for a way to run and be able to monitor it?

have you tried ms batch dos programming it yet?

for example

@echo off
cd DirectoryOfFiles
echo "Starting up..."
java -Xmx512m mainFile
pause

mainFile = main.java? DirectoryOfFiles = the directory you have all the class files in, if running file is same directory just remove this line

hopefully this is what you're asking for

Travs
  • 83
  • 1
  • 2
  • 9
  • I'm just trying to get the thing to launch, period. I'm less interesting in monitoring it once I can confirm it's actually running. My platform is an embedded linux (Angstrom) so ms batch dos programming isn't an option. Thanks for the suggestion though. – ColonelPackage Mar 26 '12 at 02:02