/
githubmirror
/
pm2
Обзор
Документация
Войти
/
githubmirror
/
pm2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/fixtures/probes.js
52 строки
1 KB
Unitech
v7 refactor
08 фев 2026, 17:04
08 фев 2026, 17:04
04fad96
Код
Авторство
О чём код?
var pmx = require('../../modules/pm2-io-bpm'); var conf = pmx.init(); var http = require('http'); http.createServer(function(req, res) { res.writeHead(200); res.end('hey'); }).listen(8000); var value_to_inspect = 0; /** * .metric, .counter, .meter, .histogram are also available (cf doc) */ var val = pmx.metric({ name : 'test-probe', value : function() { return value_to_inspect; }, /** * Here we set a default value threshold, to receive a notification * These options can be overriden via Keymetrics or via pm2 * More: http://bit.ly/1O02aap */ alert : { mode : 'threshold', value : 20, msg : 'test-probe alert!', action : function(val) { // Besides the automatic alert sent via Keymetrics // You can also configure your own logic to do something console.log('Value has reached %d', val); } } }); setInterval(function() { // Then we can see that this value increase over the time in Keymetrics value_to_inspect++; }, 30); process.on('message', function(msg) { if (msg == 'shutdown') { console.log('Closing all connections...'); setTimeout(function() { console.log('Finished closing connections'); process.exit(0); }, 500); } });