Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- "17" | ||
- "16" | ||
- "14" | ||
- "12" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
process.on('message', function(packet) { | ||
process.send({ | ||
type : 'process:msg', | ||
data : { | ||
success : true | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |