From c105fef3a13664a46c8d7128aa3ac30ccaa3558a Mon Sep 17 00:00:00 2001 From: tknew2 Date: Fri, 7 Nov 2014 15:58:40 +0100 Subject: [PATCH] add version_management flags - tests --- lib/Interactor/InteractorDaemonizer.js | 28 ++++++--- lib/sample.json5 | 58 ------------------- test/interface/interactor.daemonizer.mocha.js | 7 +++ 3 files changed, 26 insertions(+), 67 deletions(-) delete mode 100644 lib/sample.json5 diff --git a/lib/Interactor/InteractorDaemonizer.js b/lib/Interactor/InteractorDaemonizer.js index 3e2c3a8e..4b45ac1e 100644 --- a/lib/Interactor/InteractorDaemonizer.js +++ b/lib/Interactor/InteractorDaemonizer.js @@ -290,8 +290,14 @@ InteractorDaemonizer.update = function(cb) { */ InteractorDaemonizer.getSetKeys = function(secret_key, public_key, machine_name, cb) { var os = require('os'); + + /** + * Default values + */ var create_file = false; - var reverse_interact = false; + var reverse_interact = true; + var version_management_active = true; + var version_management_password = null; // If object if (secret_key && typeof(secret_key) == 'object') { @@ -309,6 +315,12 @@ InteractorDaemonizer.getSetKeys = function(secret_key, public_key, machine_name, public_key = public_key ? public_key : interaction_conf.public_key; machine_name = machine_name ? machine_name : interaction_conf.machine_name; reverse_interact = interaction_conf.reverse_interact || true; + + if (interaction_conf.version_management) { + version_management_password = interaction_conf.version_management.password || version_management_password; + version_management_active = interaction_conf.version_management.active || version_management_active; + } + } catch (e) { debug('Interaction file does not exists'); create_file = true; @@ -339,8 +351,11 @@ InteractorDaemonizer.getSetKeys = function(secret_key, public_key, machine_name, secret_key : secret_key, public_key : public_key, machine_name : machine_name, - reverse_interact : reverse_interact - + reverse_interact : reverse_interact, + version_management : { + active : version_management_active, + password : version_management_password + } }; fs.writeFileSync(cst.INTERACTION_CONF, json5.stringify(new_interaction_conf, null, 4)); } catch(e) { @@ -351,12 +366,7 @@ InteractorDaemonizer.getSetKeys = function(secret_key, public_key, machine_name, * Don't block the event loop */ process.nextTick(function() { - cb(null, { - secret_key : secret_key, - public_key : public_key, - machine_name : machine_name, - reverse_interact : reverse_interact - }); + cb(null, new_interaction_conf); }); }; diff --git a/lib/sample.json5 b/lib/sample.json5 deleted file mode 100644 index d5882c42..00000000 --- a/lib/sample.json5 +++ /dev/null @@ -1,58 +0,0 @@ -{ - /** - * This is a sample configuration file for PM2 - */ - - /** - * Here we declare the apps that must be managed by PM2 - * All options are listed here: - * https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#json-app-declaration - * - */ - apps : [ - - // First application - { - name : "API", - script : "app.js", - env: { - COMMON_VARIABLE: "true" - }, - env_production : { - NODE_ENV: "production" - } - }, - - // Second application - { - name : "WEB", - script : "web.js" - } - - ], - - - /** - * PM2 help you to deploy apps over your servers - * For more help go to : - * https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#deployment-pm2--090 - */ - 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" - } - } -} diff --git a/test/interface/interactor.daemonizer.mocha.js b/test/interface/interactor.daemonizer.mocha.js index 8a1a89a1..5022826f 100644 --- a/test/interface/interactor.daemonizer.mocha.js +++ b/test/interface/interactor.daemonizer.mocha.js @@ -32,6 +32,9 @@ describe('Daemonizer interactor', function() { should(err).be.null; data.secret_key.should.eql('XXXS'); data.public_key.should.eql('XXXP'); + + should.exist(data.version_management.active); + should(data.version_management.password).be.null; try { fs.statSync(cst.INTERACTION_CONF); } catch(e) { @@ -62,6 +65,10 @@ describe('Daemonizer interactor', function() { var interaction_conf = json5.parse(fs.readFileSync(cst.INTERACTION_CONF)); interaction_conf.secret_key.should.eql('XXXS2'); interaction_conf.public_key.should.eql('XXXP2'); + + should.exist(interaction_conf.version_management.active); + should(interaction_conf.version_management.password).be.null; + interaction_conf.machine_name.should.eql(os.hostname()); return done(); });