Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby daemons and JRuby - alternative options

Tags:

fork

ruby

jruby

I have an app that I am migrating from Ruby to JRuby (due to need for better Web Service Security support via Java). One of the gems I use is daemons to create a background job.

The issue is that it use fork+exec to create the background process, but thats a no-no with JRuby.

So - is there an alternative gem/wrapper for creating background jobs?

My current thoughts are to just call rake from a shell script and let the rake task run forever...

Thanks in advance, Chris.

UPDATE We are currently using a couple of Java threading related wrappers, namely https://github.com/jmettraux/rufus-scheduler and https://github.com/philostler/acts_as_executor

like image 911
Chris Kimpton Avatar asked Mar 18 '11 08:03

Chris Kimpton


1 Answers

Since you cannot fork in JRuby you are basically left with having to refactor your daemon code so that the daemon can be executed as a standard foreground application then create a separate daemon launcher that will run and background the daemon. You can look at spoon and also check this gist which uses spoon to create a more elaborate launcher. Also jruby-jsvc provides the glue to use jsvc with a JRuby daemon.

like image 65
Colin Surprenant Avatar answered Nov 15 '22 03:11

Colin Surprenant