在尝试了几个小时(也尝试了上帝和 Bluepill)之后,我决定在这里问我的问题,因为我完全不知道如何解决这个问题。
我有一个 Rails 应用程序。我想使用 Thin 作为我的应用服务器。我想使用 Monit 来监控我的 Thin 实例。我使用 RVM 作为本地用户来管理我的 Ruby 版本。
我设置了以下监控文件,它可能会做我想做的事,但不会:
check process thin-81
with pidfile /Users/Michael/Desktop/myapp/tmp/pids/thin.81.pid
start program = "/Users/Michael/.rvm/gems/ruby-1.9.2-p180/bin/thin start -c /Users/Michael/Desktop/myapp -e production -p 81 -d -P tmp/pids/thin.81.pid"
stop program = "/Users/Michael/.rvm/gems/ruby-1.9.2-p180/bin/thin stop -c /Users/Michael/Desktop/myapp -P tmp/pids/thin.81.pid"
if totalmem is greater than 150.0 MB for 2 cycles then restart
如果我只是将其复制/粘贴start program
到命令行(在 Monit 之外),它就可以工作。stop program
之后停止 Thin 实例也是如此。但是,通过 Monit 运行它似乎不起作用。
以详细模式运行它会-v
产生以下结果:
monit: pidfile '/Users/Michael/Desktop/myapp/tmp/pids/thin.81.pid' does not exist
这让我相信 Thin 从不初始化。Monit 是作为什么运行的root
吗?因为如果确实如此,那么它显然不会安装正确的 gem,因为我使用的是 RVM 而不是“系统”Ruby。我目前在 OSX 上(但最终会部署到 Linux)——有人知道这可能是什么原因吗?如果Monit是通过root运行的,我怎么能让它使用RVM呢?或者我可以告诉 Monit 执行启动/停止程序Michael:staff
吗(我假设它会在 OSX 上?)
任何帮助深表感谢!