Ruby daemons and JRuby - alternative options

≯℡__Kan透↙ 提交于 2019-12-30 03:27:30

问题


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


回答1:


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.




回答2:


You might be interested in http://torquebox.org/ it includes scheduling.




回答3:


There is an alternative, called Spoon written by Charles Nutter. See his blog http://blog.headius.com/2009/05/fork-and-exec-on-jvm-jruby-to-rescue.html and the gist https://gist.github.com/321084 for an example.




回答4:


I created a gem for the easy creation of Ruby & JRuby daemons: raad (Ruby as a daemon). It works identically with MRI Ruby or JRuby, simple, lightweight, transparent.



来源:https://stackoverflow.com/questions/5349629/ruby-daemons-and-jruby-alternative-options

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!