Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

start-stop-daemon and java program

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.

like image 695
ColonelPackage Avatar asked Mar 26 '12 01:03

ColonelPackage


People also ask

What is start/stop daemon?

start-stop-daemon is used to control the creation and termination of system-level processes. Using one of the matching options, start-stop-daemon can be configured to find existing instances of a running process. Note: unless --pid or --pidfile are specified, start-stop-daemon behaves similar to killall(1).

How to stop daemon in linux?

Issue the kill -15 command with the process identifier number to stop the daemons. For AIX® and Linux x86_64 GPFS™ file systems, issue the command dmkilld to stop the recall daemons. Verify that the daemons are no longer running.


1 Answers

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.

like image 95
Daniel Sokolowski Avatar answered Oct 03 '22 08:10

Daniel Sokolowski