add version_management flags - tests

This commit is contained in:
tknew2 2014-11-07 15:58:40 +01:00
parent ce3c19959f
commit c105fef3a1
3 changed files with 26 additions and 67 deletions

View File

@ -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);
});
};

View File

@ -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"
}
}
}

View File

@ -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();
});