UNPKG

940 BJavaScriptView Raw
1var path = require('path'),
2 async = require('utile').async,
3 forever = require('../lib/forever');
4
5function startServer (port, next) {
6 var child = new (forever.Monitor) (script, {
7 options: [ '--port', port],
8 silent: true
9 });
10
11 child.start();
12 child.on('start', function (_, data) {
13 console.log('Forever process running server.js on ' + port);
14 next(null, child);
15 });
16}
17
18// Array config data
19var script = path.join(__dirname, 'server.js'),
20 ports = [8080, 8081, 8082];
21
22async.map(ports, startServer, function (err, monitors) {
23 forever.startServer(monitors, function () {
24 //
25 // Now that the server has started, run `forever.list()`
26 //
27 forever.list(false, function (err, data) {
28 if (err) {
29 console.log('Error running `forever.list()`');
30 console.dir(err);
31 }
32
33 console.log('Data returned from `forever.list()`');
34 console.dir(data)
35 })
36 });
37});
\No newline at end of file