Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making a command-line app "keep going"

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an accepted coding idiom for having your java application follow this scenario?

I start the program with a shell script or batch file, and the script will complete and exit, but the program is actually still running.

Something like the Tomcat startup scripts.

The second part of the question is... is there an idiom for the 'shutdown' half of this equation (that is relatively simple to implement)? I think the Tomcat shutdown script uses the fact that the Tomcat executable listens on a certain secret ( but known ) port for a 'shutdown signal'.

Is this the best way to do this sort of thing?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sourceforge has a Java Daemon Launcher that you might want to look at.
[ May 22, 2003: Message edited by: Cindy Glass ]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm dragging this up again, because it's on my radar at work again.

Basically, I'm using the Quartz package to provide a server-wide scheduling service. It's basically cron, only accessible from java applications through a very nice API.

The problem is that I have written a small 'launcher' class that will start my scheduler, but when this class is forcefully 'terminated' (in Unix, by ctrl-C'ing the XWindow), then my scheduler goes away.

So the answer would seem to be using some OS-level script trickery. like using nohup and the & to get my prompt back.

And then I ran across this (old) JSR: http://www.jcp.org/en/jsr/detail?id=96

The gap they refer to? I'm in it.

That sf project doesn't even have code yet Cindy. I'm thinking I'll just have to go the OS route and write clever little scripts that make use of pids and what not.

I shoulda stayed awake in sysadmin class. Oh wait.. I didn't have any of those, I'm a programmer!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic