Merge branch 'development' of https://github.com/Unitech/PM2 into development

This commit is contained in:
Jean-Nicolas LAGNEAU 2014-11-12 16:30:29 +01:00
commit cea819b960
5 changed files with 66 additions and 20 deletions

View File

@ -6,9 +6,10 @@ branches:
- api
- travis
node_js:
- "0.11.14"
- "0.11"
- "0.11.13"
- "0.10"
- "0.10.32"
- "0.10.31"
- "0.10.30"
- "0.10.29"

View File

@ -70,7 +70,7 @@ var default_conf = {
GRACEFUL_TIMEOUT : parseInt(process.env.PM2_GRACEFUL_TIMEOUT) || 8000,
GRACEFUL_LISTEN_TIMEOUT : parseInt(process.env.PM2_GRACEFUL_LISTEN_TIMEOUT) || 4000,
WORKER_INTERVAL : 30000,
WORKER_INTERVAL : process.env.PM2_WORKER_INTERVAL || 30000,
DEBUG : process.env.PM2_DEBUG || false,
WEB_INTERFACE : parseInt(process.env.PM2_API_PORT) || 9615,

View File

@ -383,5 +383,5 @@ God.finalizeProcedure = function finalizeProcedure(proc) {
});
};
// var Worker = require('./Worker.js');
// Worker.start();
require('./Worker.js')(God);
God.Worker.start();

View File

@ -1,20 +1,44 @@
var God = require('./God.js');
var cst = require('../constants.js');
var vizion = require('vizion');
var Methods = {};
var timer = null;
var cst = require('../constants.js');
var tasks = function() { // do things here
console.log('COUCOU');
}
Methods.start = function() {
timer = setInterval(tasks, 1000 || cst.WORKER_INTERVAL);
}
module.exports = function(God) {
var timer = null;
Methods.stop = function() {
if (timer !== null)
clearInterval(timer);
}
God.Worker = {};
module.exports = Methods;
var versioning_refresh = function() {
var processes = God.clusters_db;
if (processes && typeof(processes) === 'object') {
for (var i in processes) {
if (processes[i] && processes[i].pm2_env.versioning) {
vizion.analyze({folder:processes[i].pm2_env.versioning.repo_path},
function(err, meta) {
if (err === null) {
if (processes[i] && processes[i].pm2_env) {
var repo_path = processes[i].pm2_env.versioning.repo_path;
processes[i].pm2_env.versioning = meta;
processes[i].pm2_env.versioning.repo_path = repo_path;
}
}
});
}
}
}
};
var tasks = function() {
versioning_refresh();
};
God.Worker.start = function() {
console.log('[PM2] WORKER STARTED with refreshing interval: '+cst.WORKER_INTERVAL);
timer = setInterval(tasks, cst.WORKER_INTERVAL);
};
God.Worker.stop = function() {
if (timer !== null)
clearInterval(timer);
};
};

View File

@ -10,9 +10,12 @@ cd $file_path
#
# Testing pull,forward,backward methods
#
git config --global user.email "jshkurti@student.42.fr"
git config --global user.name "jshkurti"
git clone https://github.com/keymetrics/app-playground.git
cd app-playground
git checkout hotfix
export PM2_WORKER_INTERVAL=1000
$pm2 start ./process.json --name app
sleep 5
@ -20,7 +23,7 @@ OUT=`$pm2 ls | grep errored | wc -l`
[ $OUT -eq 1 ] || fail "$1"
success "$1"
OUT=`$pm2 desc 0 | grep remote | egrep -oh 'https://([^ ]+)'`
OUT=`$pm2 info 0 | grep remote | egrep -oh 'https://([^ ]+)'`
[ $OUT = "https://github.com/keymetrics/app-playground.git" ] || fail "$1"
success "$1"
@ -44,6 +47,24 @@ OUT=`$pm2 ls | grep "16 " | wc -l`
[ $OUT -eq 1 ] || fail "$1"
success "$1"
#
# Testing refresh-versioning worker
#
OUT=`$pm2 jlist | egrep -oh '"unstaged":true' | wc -c`
[ $OUT -eq 16 ] || fail "$1"
success "$1"
git add --all
git commit -m 'staged now'
sleep 5
OUT=`$pm2 jlist | egrep -oh '"unstaged":false' | wc -c`
[ $OUT -eq 17 ] || fail "$1"
success "$1"
OUT=`$pm2 jlist | egrep -oh '"ahead":true' | wc -c`
[ $OUT -eq 13 ] || fail "$1"
success "$1"
$pm2 kill
cd ..
rm -rf ./app-playground