使用 monit 控制 node.js pm2 响应时间

使用 monit 控制 node.js pm2 响应时间

我想使用monit重新加载功能pm2 node.js如果响应时间超过 2 秒,则站点。

这是我的监控配置/etc/monit/monitrc

check process pm2 with pidfile "/root/.pm2/pids/siteName9000.pid" 
        start program = "/usr/local/bin/pm2 start ~/pathToNodeApp/9000/app.js --name siteName9000" 
        stop program  = "/usr/local/bin/pm2 stop siteName9000" 
        if failed port 9000 protocol HTTP 
            request / 
            with timeout 2 seconds 
            then restart

然后在控制台中运行:

# monit restart pm2

然后在控制台中运行:

# monit -d 10 -c /etc/monit/monitrc

每 10 秒检查一次。

然后在监视日志中/var/log/monit.log我看到:

[MSK May 18 06:57:05] info     : 'pm2' restart on user request
[MSK May 18 06:57:05] info     : monit daemon with PID 22480 awakened
[MSK May 18 06:57:05] info     : Awakened by User defined signal 1
[MSK May 18 06:57:05] info     : 'pm2' trying to restart
[MSK May 18 06:57:05] info     : 'pm2' start: /usr/local/bin/pm2
[MSK May 18 06:57:36] error    : 'pm2' failed to start
[MSK May 18 06:57:36] info     : 'pm2' restart action done
[MSK May 18 06:58:27] info     : Awakened by User defined signal 1
[MSK May 18 06:58:27] error    : 'pm2' process is not running
[MSK May 18 06:58:27] info     : 'pm2' trying to restart
[MSK May 18 06:58:27] info     : 'pm2' start: /usr/local/bin/pm2
[MSK May 18 06:58:27] info     : monit daemon with PID 22480 awakened
[MSK May 18 06:58:58] error    : 'pm2' failed to start
[MSK May 18 07:00:58] error    : 'pm2' process is not running
[MSK May 18 07:00:58] info     : 'pm2' trying to restart
[MSK May 18 07:00:58] info     : 'pm2' start: /usr/local/bin/pm2

所以我的监控配置不起作用。

相关内容