Monit&backgroundrb自定义gempath

我试图用monit来监视一个backgroundrb进程(偶尔会被杀死),但是我似乎无法看到启动或停止命令的工作(我简单地得到'执行失败') – 虽然他们在命令中工作正常提示。

我没有做任何特别复杂的事情:

check process backgroundrb_11006 with pidfile "/home/user/site/tmp/pids/backgroundrb_11006.pid" start = "/usr/bin/ruby /home/user/site/script/backgroundrb start" stop = "/usr/bin/ruby /home/user/site/script/backgroundrb stop" if cpu > 90% for 2 cycles then restart if totalmem > 512 MB for 2 cycles then restart if 4 restarts within 4 cycles then timeout group backgroundrb 

我有一个自定义的位置,像我的一些gem像包(/home/user/.gem/ruby/1.8/bin),我怀疑部分问题是,monit使用斯巴达PATH(引用http:/ / /mmonit.com/monit/documentation/monit.html – PATH = / bin:/ usr / bin:/ sbin:/ usr / sbin),渲染这些gems无法访问。 此外,我在backgroundrbdebugging日志中没有得到任何错误。

我很乐意听到任何人有任何想法如何调整backgroundrb(或我的启动/停止命令),以使这项工作。

干杯,沃恩。

您可以使用正确的path设置自定义启动/停止脚本,然后使用这些脚本monit。

非常简单的启动脚本(backgroundrb_monit_start)

 #!/bin/sh PATH=/bin:/usr/bin:/sbin:/usr/sbin:/add/your/other/paths GEM_HOME=/home/mygemrepository /usr/bin/ruby /home/user/site/script/backgroundrb start 

和监视configuration:

 start = "/usr/bin/ruby /home/user/site/script/backgroundrb_monit_start"