forked from Unitech/pm2
-
Notifications
You must be signed in to change notification settings - Fork 0
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
14 changed files
with
264 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
const PM2 = require('../..'); | ||
|
||
var pm2 = new PM2.custom({ | ||
cwd : __dirname + '/elements' | ||
}); | ||
|
||
|
||
pm2.start([{ | ||
script : 'error.js' | ||
}, { | ||
script : 'metric.js' | ||
}, { | ||
script : 'counter.js' | ||
}, { | ||
script : 'meter.js' | ||
}, { | ||
script : 'histogram.js' | ||
}, { | ||
script : 'event.js' | ||
}, { | ||
script : 'notify.js' | ||
}, { | ||
script : 'log.js' | ||
}, { | ||
script : 'log-cluster.js', | ||
instances : 2 | ||
}, { | ||
script : 'http.js' | ||
}, { | ||
script : 'cluster.js', | ||
instances : 4, | ||
env : { | ||
PORT : 9803 | ||
} | ||
}, { | ||
script : 'trace.js', | ||
trace : true | ||
}], (err, procs) => { | ||
console.log(`${procs.length} test apps started`); | ||
pm2.disconnect(); | ||
}); |
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,46 @@ | ||
|
||
var http = require('http'); | ||
|
||
http.createServer(function(req, res) { | ||
res.writeHead(200); | ||
setTimeout(function() { | ||
res.end('transaction'); | ||
}, 10); | ||
}).listen(process.env.PORT || 9010); | ||
|
||
setInterval(function() { | ||
request(['/user', '/bla', '/user/lol/delete', '/POST/POST'][Math.floor((Math.random() * 4))]); | ||
}, 140); | ||
|
||
function makeid() | ||
{ | ||
var text = ""; | ||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
|
||
for( var i=0; i < 5; i++ ) | ||
text += possible.charAt(Math.floor(Math.random() * possible.length)); | ||
|
||
return text; | ||
} | ||
|
||
function request(path) { | ||
var options = { | ||
hostname: '127.0.0.1' | ||
,port: 9010 | ||
,path: path || '/users' | ||
,method: 'GET' | ||
,headers: { 'Content-Type': 'application/json' } | ||
}; | ||
|
||
var req = http.request(options, function(res) { | ||
res.setEncoding('utf8'); | ||
res.on('data', function (data) { | ||
//console.log(data); | ||
}); | ||
}); | ||
req.on('error', function(e) { | ||
console.log('problem with request: ' + e.message); | ||
}); | ||
req.end(); | ||
|
||
} |
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,12 @@ | ||
|
||
|
||
const pmx = require('pmx'); | ||
const Probe = pmx.probe(); | ||
|
||
var metric = Probe.counter({ | ||
name : 'Counter' | ||
}); | ||
|
||
setInterval(function() { | ||
metric.inc() | ||
}, 500); |
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,4 @@ | ||
|
||
setInterval(function() { | ||
new Error('toto'); | ||
}, 10); |
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 @@ | ||
|
||
const pmx = require('pmx'); | ||
|
||
setInterval(function() { | ||
pmx.emit('user:register', { | ||
user : 'Alex registered', | ||
email : '[email protected]' | ||
}); | ||
}, 200); |
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,15 @@ | ||
|
||
|
||
const pmx = require('pmx'); | ||
const Probe = pmx.probe(); | ||
|
||
var metric = Probe.histogram({ | ||
name : 'Histogram' | ||
}); | ||
|
||
var latency; | ||
|
||
setInterval(function() { | ||
latency = Math.round(Math.random() * 100); | ||
metric.update(latency); | ||
}, 100); |
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,46 @@ | ||
|
||
var http = require('http'); | ||
|
||
http.createServer(function(req, res) { | ||
res.writeHead(200); | ||
setTimeout(function() { | ||
res.end('transaction'); | ||
}, 10); | ||
}).listen(process.env.PORT || 9010); | ||
|
||
setInterval(function() { | ||
request(['/user', '/bla', '/user/lol/delete', '/POST/POST'][Math.floor((Math.random() * 4))]); | ||
}, 140); | ||
|
||
function makeid() | ||
{ | ||
var text = ""; | ||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
|
||
for( var i=0; i < 5; i++ ) | ||
text += possible.charAt(Math.floor(Math.random() * possible.length)); | ||
|
||
return text; | ||
} | ||
|
||
function request(path) { | ||
var options = { | ||
hostname: '127.0.0.1' | ||
,port: 9010 | ||
,path: path || '/users' | ||
,method: 'GET' | ||
,headers: { 'Content-Type': 'application/json' } | ||
}; | ||
|
||
var req = http.request(options, function(res) { | ||
res.setEncoding('utf8'); | ||
res.on('data', function (data) { | ||
//console.log(data); | ||
}); | ||
}); | ||
req.on('error', function(e) { | ||
console.log('problem with request: ' + e.message); | ||
}); | ||
req.end(); | ||
|
||
} |
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,4 @@ | ||
setInterval(function() { | ||
console.log('log'); | ||
console.error('log'); | ||
}, 200); |
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,5 @@ | ||
|
||
setInterval(function() { | ||
console.log('log'); | ||
console.error('log'); | ||
}, 200); |
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,11 @@ | ||
|
||
const pmx = require('pmx'); | ||
const Probe = pmx.probe(); | ||
|
||
var metric = Probe.meter({ | ||
name : 'Meter' | ||
}); | ||
|
||
setInterval(function() { | ||
metric.mark() | ||
}, 200); |
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 @@ | ||
|
||
const pmx = require('pmx'); | ||
const Probe = pmx.probe(); | ||
|
||
var data = 10; | ||
|
||
var metric = Probe.metric({ | ||
name : 'Realtime user', | ||
value : function() { | ||
return data; | ||
} | ||
}); | ||
|
||
setInterval(function() { | ||
data = Math.random(); | ||
}, 500); |
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,6 @@ | ||
|
||
const pmx = require('pmx'); | ||
|
||
setInterval(function() { | ||
pmx.notify({ success : false }); | ||
}, 200); |
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,46 @@ | ||
|
||
var http = require('http'); | ||
|
||
http.createServer(function(req, res) { | ||
res.writeHead(200); | ||
setTimeout(function() { | ||
res.end('transaction'); | ||
}, 10); | ||
}).listen(9016); | ||
|
||
setInterval(function() { | ||
request(['/user', '/bla', '/user/lol/delete', '/POST/POST'][Math.floor((Math.random() * 4))]); | ||
}, 140); | ||
|
||
function makeid() | ||
{ | ||
var text = ""; | ||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
|
||
for( var i=0; i < 5; i++ ) | ||
text += possible.charAt(Math.floor(Math.random() * possible.length)); | ||
|
||
return text; | ||
} | ||
|
||
function request(path) { | ||
var options = { | ||
hostname: '127.0.0.1' | ||
,port: 9016 | ||
,path: path || '/users' | ||
,method: 'GET' | ||
,headers: { 'Content-Type': 'application/json' } | ||
}; | ||
|
||
var req = http.request(options, function(res) { | ||
res.setEncoding('utf8'); | ||
res.on('data', function (data) { | ||
//console.log(data); | ||
}); | ||
}); | ||
req.on('error', function(e) { | ||
console.log('problem with request: ' + e.message); | ||
}); | ||
req.end(); | ||
|
||
} |
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