diff --git a/.travis.yml b/.travis.yml index b3ce156c3..8ffe09018 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: node_js node_js: + - "17" - "16" - "14" - "12" diff --git a/examples/send-msg/pm2-app.js b/examples/send-msg/pm2-app.js new file mode 100644 index 000000000..b49167b14 --- /dev/null +++ b/examples/send-msg/pm2-app.js @@ -0,0 +1,9 @@ + +process.on('message', function(packet) { + process.send({ + type : 'process:msg', + data : { + success : true + } + }); +}); diff --git a/examples/send-msg/pm2-msg.js b/examples/send-msg/pm2-msg.js new file mode 100644 index 000000000..9df5fdb7b --- /dev/null +++ b/examples/send-msg/pm2-msg.js @@ -0,0 +1,29 @@ + +const pm2 = require('../..') + +console.log(pm2) + +pm2.connect(function() { + pm2.sendDataToProcessId({ + // id of procces from "pm2 list" command or from pm2.list(errback) method + id : '1', + + // process:msg will be send as 'message' on target process + type : 'process:msg', + + // Data to be sent + data : { + some : 'data' + }, + + topic: true + }, function(err, res) { + }) +}) + +// Listen to messages from application +pm2.launchBus(function(err, pm2_bus) { + pm2_bus.on('process:msg', function(packet) { + console.log(packet) + }) +}) diff --git a/examples/send-msg/t2.js b/examples/send-msg/t2.js new file mode 100644 index 000000000..6190469cc --- /dev/null +++ b/examples/send-msg/t2.js @@ -0,0 +1,16 @@ + +var tx2 = require('tx2') +var http = require('http') + +var meter = tx2.meter({ + name : 'req/sec', + samples : 1, + timeframe : 60 +}) + +http.createServer(function (req, res) { + meter.mark() + res.writeHead(200, {'Content-Type': 'text/plain'}) + res.write('Hello World!') + res.end() +}).listen(6001)