Ruby守护程序和JRuby-替代选项 [英] Ruby daemons and JRuby - alternative options

查看:70
本文介绍了Ruby守护程序和JRuby-替代选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要从Ruby迁移到JRuby的应用程序(由于需要通过Java更好的Web服务安全性支持).我使用的宝石之一是守护程序来创建后台作业.

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.

问题在于它使用fork + exec创建后台进程,但这与JRuby无关.

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

那么-有替代的gem/wrapper用于创建后台作业吗?

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

我目前的想法是仅从shell脚本调用rake,并让rake任务永久运行...

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

提前谢谢克里斯.

更新 我们目前正在使用几个与Java线程相关的包装器,即 https://github.com/jmettraux/rufus- Scheduler https://github.com/philostler/acts_as_executor

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

推荐答案

由于您无法在JRuby中进行分叉,因此您基本上只需要重构守护程序代码,以便可以将该守护程序作为标准前台应用程序执行,然后创建一个单独的后台程序.后台程序启动程序,它将运行后台程序并使其后台运行.您可以查看勺子并选中此 jruby-jsvc 提供了使用

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.

这篇关于Ruby守护程序和JRuby-替代选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆