diff --git a/lib/CLI.js b/lib/CLI.js index d4ecf02c..633e388a 100644 --- a/lib/CLI.js +++ b/lib/CLI.js @@ -13,7 +13,7 @@ var Satan = require('./Satan'); var Common = require('./Common'); var cst = require('../constants.js'); var extItps = require('./interpreter.json'); -var InteractorDaemonizer = require('./InteractorDaemonizer'); +var InteractorDaemonizer = require('./Interactor/InteractorDaemonizer'); var p = path; var Deploy = require('pm2-deploy'); diff --git a/lib/Interactor.js b/lib/Interactor/Interactor.js similarity index 99% rename from lib/Interactor.js rename to lib/Interactor/Interactor.js index 0fd08c68..a30e707d 100644 --- a/lib/Interactor.js +++ b/lib/Interactor/Interactor.js @@ -7,8 +7,8 @@ var crypto = require('crypto'); var fs = require('fs'); var debug = require('debug')('interface:driver'); // Interface var os = require('os'); -var cst = require('../constants.js'); -var pkg = require('../package.json'); +var cst = require('../../constants.js'); +var pkg = require('../../package.json'); var sock = axon.socket('pub'); var rep = axon.socket('rep'); diff --git a/lib/InteractorDaemonizer.js b/lib/Interactor/InteractorDaemonizer.js similarity index 98% rename from lib/InteractorDaemonizer.js rename to lib/Interactor/InteractorDaemonizer.js index 84c32753..345d4f84 100644 --- a/lib/InteractorDaemonizer.js +++ b/lib/Interactor/InteractorDaemonizer.js @@ -2,11 +2,11 @@ 'use strict'; var fs = require('fs'); -var cst = require('../constants.js'); +var cst = require('../../constants.js'); var path = require('path'); var util = require('util'); var rpc = require('pm2-axon-rpc'); -var Common = require('./Common'); +var Common = require('../Common'); var debug = require('debug')('interface:daemon'); var axon = require('axon'); diff --git a/lib/Satan.js b/lib/Satan.js index 650f7569..b7a0b13b 100644 --- a/lib/Satan.js +++ b/lib/Satan.js @@ -107,7 +107,7 @@ Satan.remoteWrapper = function() { // Only require here because God init himself var God = require('./God'); - var InteractorDaemonizer = require('./InteractorDaemonizer.js'); + var InteractorDaemonizer = require('./Interactor/InteractorDaemonizer.js'); Satan.processStateHandler(God); @@ -219,12 +219,11 @@ Satan.remoteWrapper = function() { return God.clusters_db[pm2_env.pm_id].pm2_env.axm_actions.push(msg.data.data); }); - God.bus.onAny(function(data_v) { - debug(this.event); - var self = this; - // Avoid circular structure - InteractorDaemonizer.launchAndInteract({}, function(err, data) { - pub.emit(self.event, JSON.parse(Stringify(data_v))); + InteractorDaemonizer.launchAndInteract({}, function(err, data) { + God.bus.onAny(function(data_v) { + debug(this.event); + // Avoid circular structure + pub.emit(this.event, JSON.parse(Stringify(data_v))); }); }); diff --git a/test/fixtures/ecosystem.json b/test/fixtures/ecosystem.json new file mode 100644 index 00000000..0537d5ab --- /dev/null +++ b/test/fixtures/ecosystem.json @@ -0,0 +1,33 @@ +{ + "apps" : [{ + "name" : "API", + "script" : "app.js", + "env": { + "COMMON_VARIABLE": "true" + }, + "env_production" : { + "NODE_ENV": "production" + } + },{ + "name" : "WEB", + "script" : "web.js" + }], + "deploy" : { + "production" : { + "user" : "node", + "host" : "212.83.163.1", + "ref" : "origin/master", + "repo" : "git@github.com:repo.git", + "path" : "/var/www/production", + "post-deploy" : "pm2 startOrRestart ecosystem.json --env production" + }, + "dev" : { + "user" : "node", + "host" : "212.83.163.1", + "ref" : "origin/master", + "repo" : "git@github.com:repo.git", + "path" : "/var/www/development", + "post-deploy" : "pm2 startOrRestart ecosystem.json --env dev" + } + } +}