forked from bitpay/wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.js
More file actions
executable file
·34 lines (24 loc) · 717 Bytes
/
launch.js
File metadata and controls
executable file
·34 lines (24 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /usr/bin/node
'use strict';
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) {
sys.puts(stdout)
}
function isNumber(n) {
return !isNaN(parseInt(n)) && isFinite(n);
}
var args = process.argv.slice(2);
var n_str = args[0];
if (!isNumber(n_str)) {
console.log('Program requires one numeric argument for the amount of copayers');
process.exit(1);
}
var N = parseInt(n_str);
var DEFAULT_PORT = process.env.DEFAULT_PORT || 3000;
for (var i = 0; i < N; i++) {
var port = (i + DEFAULT_PORT);
console.log('Simulating copayer #' + (i + 1) + ' at http://localhost:' + port);
var command = 'PORT=' + port + ' npm start &'
exec(command, puts);
}