I’m on linux, so I can use start-stop-daemon, but the necessary -b
switch in this case implies some hoops to check whether it *actually *
started that I’d rather avoid. It’d be nice to use something like jsvc
that can wait to be sure things are working before returning.
I found a few threads from 2008 discussing making daemons, but the best
answer I’ve found (link below) seems to be “background & nohup”, which has
the same “so… did it start?” issues.
We’ve implemented the Daemon interface that jsvc tells you to. The
trick is to bring your app up in the init method and start serving in
the start method. This lets the daemon report whether it has worked or
not before it backgrounds.
Let me know if you struggle and I’ll see if I can get you an example.
Cheers,
Nick
On Thu, 2010-07-01 at 09:48 -0700, Jeff W. wrote:
that can wait to be sure things are working before returning.
So your Daemon interface implementation is just a java class you wrote
that executes your jruby script?
Or did you implement the Daemon interface in your jruby script too?
Seems likely either could work, but I’m a little uncertain of the
division of work between $RUBY_SCRIPT and the “yourapp-java.jar”
referenced in the classpath of your script.
Yeah, it is a bit naff having to maintain a java code base - I tried
compiling ruby code (I think you’ll need a java class to use with
jsvc-daemon) with the jruby compiler but the method signatures didn’t
look right when I inspected the bytecode, but I could have been doing
something wrong. We have some other java code anyway, so not a massive
problem for us, plus I’m ex-Java, so i get to feel nostalgic using maven
for a while
Here is a gist of a java class similar to the one we use
It refers to a Daemon module, which offers the interface/API between
JRubyDaemon and our application(s). We run a bunch of different
daemons, so this is just a code re-use thing.
Time permitting, I should be able to create a generic version and host
it somewhere, so you won’t have to maintain your own java code as that
is a PITA for some.
Cheers
Nick
On Fri, 2010-07-02 at 10:19 -0700, Jeff W. wrote:
-----Original Message-----
trick is to bring your app up in the init method and start serving in
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.