【发布时间】:2014-07-04 07:53:35
【问题描述】:
我已经安装并(希望)配置了 Monit,在 /etc/monit.d 中创建了一个新任务(在 CentOS 6.5 上)
我的任务文件名为test:
check host test with address 127.0.0.1
start program = "/usr/local/bin/node /var/node/test/index.js" as uid node and gid node
stop program = "/usr/bin/pkill -f 'node /var/node/test/index.js'"
if failed port 7000 protocol HTTP
request /
with timeout 10 seconds
then restart
当我跑步时:
service monit restart
在我的监控日志中出现:
[CEST Jul 4 09:50:43] info : monit daemon with pid [21946] killed
[CEST Jul 4 09:50:43] info : 'nsxxxxxx.ip-xxx-xxx-xxx.eu' Monit stopped
[CEST Jul 4 09:50:47] info : 'nsxxxxxx.ip-xxx-xxx-xxx.eu' Monit started
[CEST Jul 4 09:50:47] error : 'test' failed, cannot open a connection to INET[127.0.0.1:7000] via TCP
[CEST Jul 4 09:50:47] info : 'test' trying to restart
[CEST Jul 4 09:50:47] info : 'test' stop: /usr/bin/pkill
[CEST Jul 4 09:50:47] info : 'test' start: /usr/local/bin/node
我不明白为什么脚本不起作用,如果我从命令行运行它:
su node # user created for node scripts
node /var/node/test/index.js
一切正常...
我关注了this tutorial。
我该如何解决这个问题?谢谢
【问题讨论】:
-
monit 是无法启动进程还是只是无法响应端口 7000 上的 http?
-
在 ubuntu 12 中对我来说同样的问题。我用暴发户 codeplease.wordpress.com/2013/09/27/… 解决了这个问题
-
我用过 PM2,它是管理 Node.js 应用的绝佳工具