usando monit para controlar o tempo de resposta node.js pm2

1

Eu quero usar monit para poder recarregar pm2 node.js site se a resposta for maior que 2 segundos.

Esta é minha configuração de monit /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

Em seguida, no console, eu corro:

# monit restart pm2

Em seguida, no console, eu corro:

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

para fazer essa verificação a cada 10 segundos.

Então, em monit log /var/log/monit.log , vejo:

[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

Então minha configuração de monit não funciona.

    
por Maxim Yefremov 18.05.2014 / 05:11

0 respostas

Tags