简体   繁体   English

Ruby on Rails:如何在启动期间检测集群中的特定杂种实例?

[英]Ruby on Rails: How do I detect a specific mongrel instance in a cluster during startup?

We run an application with a half dozen mongrels. 我们运行一个带有六名杂种动物的应用程序。 A new feature that we've added is a scheduler (rufus-scheduler) that runs within a mongrel and provides cron-like background task processing. 我们添加的一个新功能是调度程序(rufus-scheduler),该程序在杂种中运行,并提供类似于cron的后台任务处理。 We want ot run this scheduler on only one of our mongrels but we can't figure out how -- during startup (environment.rb) -- to identify the specific mongrel to start the scheduler in. 我们只希望仅在其中一个mongrels上运行此调度程序,但是我们无法确定在启动过程中(environment.rb)如何识别要在其中启动调度程序的特定杂种。

We have set up a yaml file with a setting for the port # for the mongrel in which we would like to have the scheduler start. 我们已经建立了一个yaml文件,并为我们希望启动调度程序的杂种设置了端口号。 During startup, in enviromnent.rb, we would like to query the yaml file, get the port, and then compare this to the instance that is booting -- if it's the same, launch the scheduler. 在启动过程中,我们要在enviromnent.rb中查询yaml文件,获取端口,然后将其与正在引导的实例进行比较-如果相同,则启动调度程序。

Someone answered recently that we should look at request.port -- there is no request object when you are booting. 最近有人回答说我们应该查看request.port -引导时没有请求对象。 Where else is the port # stored? 端口号还存储在哪里? Or, how can we pass a parm to an individual mongrel or have it compare itself to a setting to identify itself? 或者,我们如何将parm传递给单个杂种,或者将其与设置进行比较以标识自己?

Thanks in advance... 提前致谢...

Russell 罗素

I asked the same question couple of weeks back. 几周前,我问了同样的问题

Gist: 要旨:

  1. A plugin named ' Rooster ' addresses this problem. 一个名为“ Rooster ”的插件解决了这个问题。
  2. Use a shared resource like a file as a way to synchronize. 使用文件之类的共享资源作为同步方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM