From dba160156055b8552e4aedff8e32f89b34087f6c Mon Sep 17 00:00:00 2001 From: Mitchell Huang Date: Mon, 7 Nov 2016 17:00:08 +0000 Subject: [PATCH 1/2] Added app.js to spawn service scripts, PM2 compatibility --- app.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..144ba7e --- /dev/null +++ b/app.js @@ -0,0 +1,24 @@ +#!/usr/bin/env node + +var spawn = require('child_process').spawn; +var process = require('process'); +var async = require('async'); + +var scripts = ['locker/locker.js', 'messagebroker/messagebroker.js', + 'bcmonitor/bcmonitor.js', 'emailservice/emailservice.js', + 'pushnotificationsservice/pushnotificationsservice.js', + 'fiatrateservice/fiatrateservice.js', 'bws.js']; + +async.eachSeries(scripts, function(script, callback) { + console.log(`Spawning ${script}`); + + var node = spawn('node', [script]); + node.stdout.on('data', (data) => { + console.log(`${data}`); + }); + node.stderr.on('data', (data) => { + console.error(`${data}`); + }); + + callback(); +}); From dee50e8d30ef1ffd52382402cc8ad0b5bd0636da Mon Sep 17 00:00:00 2001 From: Mitchell Huang Date: Mon, 7 Nov 2016 17:11:55 +0000 Subject: [PATCH 2/2] Remove unused process require, fixed spacing --- app.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 144ba7e..27f90de 100644 --- a/app.js +++ b/app.js @@ -1,13 +1,12 @@ #!/usr/bin/env node var spawn = require('child_process').spawn; -var process = require('process'); var async = require('async'); var scripts = ['locker/locker.js', 'messagebroker/messagebroker.js', - 'bcmonitor/bcmonitor.js', 'emailservice/emailservice.js', - 'pushnotificationsservice/pushnotificationsservice.js', - 'fiatrateservice/fiatrateservice.js', 'bws.js']; + 'bcmonitor/bcmonitor.js', 'emailservice/emailservice.js', + 'pushnotificationsservice/pushnotificationsservice.js', + 'fiatrateservice/fiatrateservice.js', 'bws.js']; async.eachSeries(scripts, function(script, callback) { console.log(`Spawning ${script}`); @@ -19,6 +18,6 @@ async.eachSeries(scripts, function(script, callback) { node.stderr.on('data', (data) => { console.error(`${data}`); }); - + callback(); });