【问题标题】:Monit does not start Node scriptMonit 不启动节点脚本
【发布时间】: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 应用的绝佳工具

标签: node.js monit


【解决方案1】:

同样的方法对我也不起作用,我所做的是制作了一个启动/停止脚本并在 start programstop program 参数中传递该脚本。
您可以从 here
找到启动/停止脚本示例 下面是我对 node.js 应用程序的监控设置

check host my-node-app with address 127.0.0.1
    start program = "/etc/init.d/my-node-app start"
    stop program = "/etc/init.d/my-node-app stop"
    if failed port 3002 protocol HTTP
        request /
        with timeout 5 seconds
        then restart
    if 5 restarts within 5 cycles then timeout

【讨论】:

    猜你喜欢
    • 2014-06-07
    • 1970-01-01
    • 2023-03-04
    • 2021-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-14
    相关资源
    最近更新 更多