本文介绍了如何使用monit监视delayed_job的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网络上是否有通过来监视delay_job的示例?

Are there any examples on the web of how to monitor delayed_job with Monit?

我能找到的所有使用,但我拒绝使用上帝,因为Ruby中长期运行的进程通常很烂。 (上帝邮件列表中的最新帖子?。)

Everything I can find uses God, but I refuse to use God since long running processes in Ruby generally suck. (The most current post in the God mailing list? God Memory Usage Grows Steadily.)

更新:延迟工作现在带有。

Update: delayed_job now comes with a sample monit config based on this question.

推荐答案

这就是我的工作方式。


  1. 使用除了得到积极维护外,该版本还有一个不错的 script / delayed_job 守护程序,可以与monit一起使用。关于此版本的 delayed_job ,Railscasts具有。 code>()。该脚本还具有其他一些不错的功能,例如能够运行多个工作程序。我不在这里介绍。

  2. 安装监控程序。我是从源代码安装的,因为Ubuntu版本太荒谬了。我遵循了以获取Ubuntu软件包随附的标准init.d脚本。我还需要配置。/configure --sysconfdir = / etc / monit ,以便选择标准的Ubuntu配置目录。

  3. 编写监视脚本。这是我的想法:

  1. Use the collectiveidea fork of delayed_job besides being actively maintained, this version has a nice script/delayed_job daemon you can use with monit. Railscasts has a good episode about this version of delayed_job (ASCIICasts version). This script also has some other nice features, like the ability to run multiple workers. I don't cover that here.
  2. Install monit. I installed from source because Ubuntu's version is so ridiculously out of date. I followed these instructions to get the standard init.d scripts that come with the Ubuntu packages. I also needed to configure with ./configure --sysconfdir=/etc/monit so the standard Ubuntu configuration dir was picked up.
  3. Write a monit script. Here's what I came up with:

使用pidfile /var/www/app/shared/pids/delayed_job.pid

开始程序= / var / www / app / current / script / delayed_job -e生产开始

停止程序= / var / www / app / current / script / delayed_job -e生产停止

我将其存储在我的soucre控制系统中,并通过 include 指向它。 code> / etc / monit / monitrc 文件。

I store this in my soucre control system and point monit at it with include /var/www/app/current/config/monit in the /etc/monit/monitrc file.

我遇到的问题:


  1. daemons 必须为 script / delayed_job 安装gem跑。

  2. 您必须将Rails环境传递到 -e生产 script / delayed_job >(例如)。该文件记录在README文件中,但未在脚本的帮助输出中记录。

  3. 我使用的是Ruby Enterprise Edition,因此需要获得监视才能从该Ruby副本开始。由于的方式,我最终进行了 / usr / bin / ruby​​ / usr / bin / gem 到REE版本。

  1. daemons gem must be installed for script/delayed_job to run.
  2. You must pass the Rails environment to script/delayed_job with -e production (for example). This is documented in the README file but not in the script's help output.
  3. I use Ruby Enterprise Edition, so I needed to get monit to start with that copy of Ruby. Because of the way sudo handles the PATH in Ubuntu, I ended up symlinking /usr/bin/ruby and /usr/bin/gem to the REE versions.

调试monit时,我发现它有助于停止init.d版本并从th命令行运行它,因此您可以获得错误消息。否则很难弄清楚为什么会出问题。

When debugging monit, I found it helps to stop the init.d version and run it from the th command line, so you can get error messages. Otherwise it is very difficult to figure out why things are going wrong.

sudo /etc/init.d/monit stop
sudo monit start delayed_job

希望这有助于下一个要监视 deited_job 和monit。

Hopefully this helps the next person who wants to monitor delayed_job with monit.

这篇关于如何使用monit监视delayed_job的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 06:37