mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
var vizion = require('vizion');
|
|
|
|
var cst = require('../constants.js');
|
|
|
|
|
|
module.exports = function(God) {
|
|
var timer = null;
|
|
|
|
God.Worker = {};
|
|
|
|
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
|
|
&& processes[i].pm2_env.versioning.repo_path) {
|
|
vizion.analyze({folder:processes[i].pm2_env.versioning.repo_path},
|
|
function(err, meta) {
|
|
if (err === null) {
|
|
if (processes[i] && processes[i].pm2_env
|
|
&& processes[i].pm2_env.versioning
|
|
&& processes[i].pm2_env.versioning.repo_path) {
|
|
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);
|
|
};
|
|
};
|