确保加载 Rails 应用程序时某些进程正在运行
我想确保当我的 Rails 3 应用程序初始化或加载时,某些进程(例如 Sunspot Solr search 和 Delayed_job)正在运行。
我有点菜鸟,据我所知,我可以编写一个自定义初始化程序或使用像 God 或 Monit 这样的进程监视框架。
有人可以建议这里的最佳路径吗?
I want to ensure that certain processes like Sunspot Solr search and delayed_job are running when my Rails 3 app initializes or loads.
I'm somewhat of a noob and from what I can tell, I could write a custom initializer or use a process monitoring framework like God or Monit.
Can someone please suggest the optimal path to take here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您正在运行 Rails 应用程序,God 是一个非常好的选择。如果您不熟悉,Railscasts 有一个很好的截屏视频可以帮助您入门:
http://railscasts。 com/episodes/130-monitoring-with-god
If you are running a Rails application God is a very good option. If you are unfamiliar, Railscasts has a good screencast to get you started:
http://railscasts.com/episodes/130-monitoring-with-god
您可以编写一个初始值设定项来检查,例如
You could write an initializer that checks, something like
初始化方法的问题在于,即使所有必需的进程都在启动时运行,也不能保证它们在应用程序运行的接下来几周或几个月内继续运行。
使用监控框架——God 和 Monit 都是很好的解决方案——你可以确定,即使你的某个进程死掉了,它也会自动重新启动。此外,您还可以在发生这种情况时收到通知,以便在问题开始发生时尽早收到通知。
简而言之:与任何自制解决方案相比,监控框架很可能是更好的解决方案。
The problem with the initializer approach is that even if all your required processes are running at startup, there's is no guarantee they keep running the next few weeks or months your application is running.
Using a monitoring framework - both God and Monit are good solutions - you can be sure that even if one of your processes dies, it'll be restarted automatically. Also you can be notified when that happens, so you get notified early when problems are starting to happen.
In a nutshell: A monitoring framework will most likely be the better solution compared to any home-brewn solution.