tags:

views:

278

answers:

6

Hi.

While I found this question being answered here on SW several times, I didn't find a concluding answer what is the best approach.

I'm not looking to use any external wrapper, as I found them launching the java process under a nice level lower then themselves which potentially lowers the performance, so it seems only the shell methods are left.

I so far found 3 different shell methods:

  • start-stop-daemon
  • RedHat daemon init.d function
  • nohup on start / disown after start

What you people are using, and can recommend as the most reliable method?

Thanks.

A: 

You could try using screen (Launch screen, then launch the java program, then close[not quit] the screen)

webdestroya
A: 

I wouldn't rule out the external wrappers completely.
I have noticed some well respected software using the Tanuki Wrapper http://wrapper.tanukisoftware.org/.

This has the added advantage that the program can also be easily run as a windows service, with a consistent approach.

crowne
He is not going to be able to run this as a Windows service on Linux.
danben
Well I really haven't been watching mono developments all that closely, but that wasn't the point anyway. Why restrict the application to running on Linux only unnecessarily. Perhaps others may find the need to run the application and find themselves in a position where they can only run on windows. Rather than chase away potential users, why not limit restrictions and encourage re-use.
crowne
+2  A: 

If I want to run an application in the background as a daemon, I do it like this:

nohup java -jar MyJar &

There's nothing particularly unreliable about it - nohup keeps it from receiving a SIGHUP when you disconnect, and & runs a process in the background.

Optionally, you can redirect the output to something other than nohup.out.

danben
+1  A: 

While the standard answer to this seems to be jsvc, I have been using djb's daemon tools to be a great way to make anything into a daemon.

I have java, python and a few shell scripts all running as daemons, with a simple way to start/stop them and great logging.

I've used to run daemontools itself as root on initctl as originally designed, but after a few months I decided to run it manually, under a normal user, and using svscan-start for nicer logging.

itsadok
+1  A: 

I would use the RedHat daemon init.d function. This allows you to have the application restart when the server does. Running nohup doesn't handle server restarts, etc.

Chris Mo
+1  A: 

I've used Akuma in the past, with great success. The fact that it's a Java library really makes things easier, embedding the functionality is trivial.

gpampara