mirror of
https://github.com/Unitech/pm2.git
synced 2026-02-01 16:57:09 +00:00
remove depreacted files
This commit is contained in:
parent
719fd338ef
commit
e11ff65cfe
@ -1,88 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @file ActionMethod like restart, stop, monitor... are here
|
||||
* @author Alexandre Strzelewicz <as@unitech.io>
|
||||
* @project PM2
|
||||
*/
|
||||
|
||||
var util = require('util');
|
||||
|
||||
module.exports = function(God) {
|
||||
|
||||
God.lock = function(opts, cb) {
|
||||
var proc_name = opts.name;
|
||||
var metadata = opts.meta || {};
|
||||
var processes = God.findByName(opts.name);
|
||||
|
||||
if (processes && processes.length === 0)
|
||||
return cb(new Error('Process name ' + opts.name + ' not found'));
|
||||
|
||||
var proc_keys = Object.keys(processes);
|
||||
|
||||
for (var i = 0; i < proc_keys.length ; ++i) {
|
||||
var proc = processes[proc_keys[i]];
|
||||
var _metadata;
|
||||
|
||||
if (!(proc.pm2_env && proc.pm2_env.command))
|
||||
continue;
|
||||
|
||||
console.log('Locking %s', proc.pm2_env.pm_id);
|
||||
|
||||
if (proc.pm2_env.command.locked === true)
|
||||
return cb(new Error('Process name ' + opts.name + ' is already locked'));
|
||||
proc.pm2_env.command.locked = true;
|
||||
proc.pm2_env.command.started_at = Date.now();
|
||||
|
||||
try {
|
||||
_metadata = JSON.parse(JSON.stringify(metadata));
|
||||
} catch(e) {
|
||||
console.error(e.stack);
|
||||
_metadata = metadata;
|
||||
}
|
||||
|
||||
proc.pm2_env.command.metadata = _metadata;
|
||||
}
|
||||
|
||||
return cb(null, processes);
|
||||
};
|
||||
|
||||
God.unlock = function(opts, cb) {
|
||||
var proc_name = opts.name;
|
||||
var metadata = opts.meta || {};
|
||||
var processes = God.findByName(opts.name);
|
||||
|
||||
if (processes && processes.length === 0)
|
||||
return cb(new Error('Process name ' + opts.name + ' not found'));
|
||||
|
||||
var proc_keys = Object.keys(processes);
|
||||
|
||||
for (var i = 0; i < proc_keys.length ; ++i) {
|
||||
var proc = processes[proc_keys[i]];
|
||||
var _metadata;
|
||||
|
||||
if (!(proc.pm2_env && proc.pm2_env.command))
|
||||
continue;
|
||||
|
||||
console.log('Unlocking %s', proc.pm2_env.pm_id);
|
||||
|
||||
proc.pm2_env.command.locked = false;
|
||||
proc.pm2_env.command.finished_at = Date.now();
|
||||
|
||||
try {
|
||||
_metadata = JSON.parse(JSON.stringify(metadata));
|
||||
} catch(e) {
|
||||
console.error(e.stack);
|
||||
_metadata = metadata;
|
||||
}
|
||||
|
||||
if (typeof(proc.pm2_env.command.metadata) === 'object')
|
||||
util._extend(proc.pm2_env.command.metadata, _metadata);
|
||||
else
|
||||
proc.pm2_env.command.metadata = _metadata;
|
||||
}
|
||||
|
||||
return cb(null, processes);
|
||||
};
|
||||
|
||||
};
|
||||
@ -1,241 +0,0 @@
|
||||
|
||||
var should = require('should');
|
||||
var ipm2 = require('pm2-interface');
|
||||
var util = require('util');
|
||||
var axon = require('axon');
|
||||
var sock = axon.socket('sub');
|
||||
var cst = require('../../constants.js');
|
||||
var Plan = require('../helpers/plan.js');
|
||||
|
||||
|
||||
var nssocket = require('nssocket');
|
||||
|
||||
var Ipm2 = require('pm2-interface');
|
||||
|
||||
var APPS = require('../helpers/apps.js');
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method forkPM2
|
||||
* @return pm2
|
||||
*/
|
||||
function forkPM2() {
|
||||
var pm2 = require('child_process').fork('lib/Satan.js', [], {
|
||||
detached : true
|
||||
});
|
||||
pm2.unref();
|
||||
return pm2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method forkInteractor
|
||||
* @return CallExpression
|
||||
*/
|
||||
function forkInteractor() {
|
||||
return require('child_process').fork('lib/Interactor.js', [], {
|
||||
env : util._extend({
|
||||
PM2_MACHINE_NAME : 'test',
|
||||
PM2_SECRET_KEY : 'toto',
|
||||
PM2_PUBLIC_KEY : 'tg',
|
||||
PM2_DEBUG : true,
|
||||
NODE_ENV : 'test' // Permit to disable encryption
|
||||
}, process.env)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method bufferContain
|
||||
* @param {} buffer
|
||||
* @param {} event
|
||||
* @return contain
|
||||
*/
|
||||
function bufferContain(buffer, event) {
|
||||
var contain = false;
|
||||
buffer.data.buffer.forEach(function(dt) {
|
||||
if (dt.event == event)
|
||||
contain = dt;
|
||||
});
|
||||
return contain;
|
||||
}
|
||||
|
||||
describe.skip('Interactor', function() {
|
||||
var pm2;
|
||||
var interactor;
|
||||
var ipm2;
|
||||
var socket;
|
||||
var server;
|
||||
|
||||
after(function() {
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('should fork PM2', function(done) {
|
||||
try {
|
||||
pm2 = APPS.forkPM2();
|
||||
} catch(e) {
|
||||
done();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should start mock NSSOCKER interface', function(done) {
|
||||
server = nssocket.createServer(function (_socket) {
|
||||
console.log('new connection');
|
||||
socket = _socket;
|
||||
});
|
||||
server.listen(cst.REMOTE_REVERSE_PORT);
|
||||
done();
|
||||
});
|
||||
|
||||
describe('External interaction', function() {
|
||||
|
||||
beforeEach(function(done) {
|
||||
ipm2 = Ipm2();
|
||||
|
||||
ipm2.once('ready', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
ipm2.disconnect();
|
||||
});
|
||||
|
||||
|
||||
it('should fork Interactor', function(done) {
|
||||
sock.bind(3900);
|
||||
interactor = forkInteractor();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should receive an intervaled message (sent every sec)', function(done) {
|
||||
sock.once('message', function(raw_data) {
|
||||
var data = JSON.parse(raw_data);
|
||||
|
||||
data.should.have.properties(['public_key', 'sent_at', 'data']);
|
||||
data.data.buffer.length.should.eql(2); // Include monitoring and server data
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
var cur_id = 0;
|
||||
|
||||
it('should on application start, buffer contain a process:online event', function(done) {
|
||||
sock.once('message', function(raw_data) {
|
||||
var data = JSON.parse(raw_data);
|
||||
|
||||
if (bufferContain(data, 'process:online')) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
APPS.launchApp(ipm2, 'echo.js', 'echo', function(err, proc) {
|
||||
should(err).be.null;
|
||||
proc.length.should.eql(1);
|
||||
proc[0].pm2_env.status.should.eql('online');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('should on launch custom action', function(done) {
|
||||
APPS.launchApp(ipm2, 'events/custom_action.js', 'custom_action', function(err, proc) {
|
||||
cur_id = proc[1].pm2_env.pm_id;
|
||||
should(err).be.null;
|
||||
|
||||
setTimeout(function() {
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
console.log(procs);
|
||||
procs.length.should.eql(2);
|
||||
procs[1].pm2_env.restart_time.should.eql(0);
|
||||
done();
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('should get information about instance', function(done) {
|
||||
|
||||
socket.send('ask');
|
||||
|
||||
socket.data('ask:rep', function (data) {
|
||||
data.success.should.eql.true;
|
||||
data.machine_name.should.eql('test');
|
||||
data.public_key.should.eql('tg');
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
it('should trigger action like remote AXM', function(done) {
|
||||
var plan = new Plan(2, done);
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method rcv
|
||||
* @param {} raw_data
|
||||
* @return
|
||||
*/
|
||||
function rcv(raw_data) {
|
||||
var data = JSON.parse(raw_data);
|
||||
var ret;
|
||||
//console.log(data.data.buffer);
|
||||
if ((ret = bufferContain(data, 'axm:reply'))) {
|
||||
ret.should.have.properties([
|
||||
'event', 'process_id', 'process_name', 'data', 'at'
|
||||
]);
|
||||
ret.data.data.success.should.be.true;
|
||||
sock.removeListener('message', rcv);
|
||||
plan.ok(true);
|
||||
}
|
||||
}
|
||||
// 2 - He should then receive an axm:reply on completion
|
||||
sock.on('message', rcv);
|
||||
|
||||
socket.send('trigger:action', {
|
||||
process_id : cur_id,
|
||||
action_name : 'refresh:db',
|
||||
type : 'remote_action'
|
||||
});
|
||||
|
||||
socket.data('trigger:action:success', function() {
|
||||
console.log('Action has been sent');
|
||||
plan.ok(true);
|
||||
});
|
||||
|
||||
socket.data('trigger:action:failure', function(e) {
|
||||
console.log(e);
|
||||
throw new Error(e);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// it('should remove all socket data and stuff if server disconnect', function(done) {
|
||||
|
||||
// server.close();
|
||||
// server = nssocket.createServer(function (_socket) {
|
||||
// console.log('new connection');
|
||||
// socket = _socket;
|
||||
// done();
|
||||
// });
|
||||
|
||||
// server.listen(cst.REMOTE_REVERSE_PORT);
|
||||
|
||||
// });
|
||||
|
||||
|
||||
it('should kill alive processes', function(done) {
|
||||
process.kill(pm2.pid);
|
||||
process.kill(interactor.pid);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@ -1,504 +0,0 @@
|
||||
|
||||
var should = require('should');
|
||||
var util = require('util');
|
||||
var axon = require('axon');
|
||||
var path = require('path');
|
||||
|
||||
var Plan = require('../helpers/plan.js');
|
||||
var APPS = require('../helpers/apps.js');
|
||||
var Ipm2 = require('pm2-interface');
|
||||
|
||||
describe('PM2 BUS / RPC', function() {
|
||||
var pm2;
|
||||
var ipm2;
|
||||
|
||||
after(function(done) {
|
||||
ipm2 = Ipm2();
|
||||
|
||||
ipm2.once('ready', function() {
|
||||
ipm2.rpc.killMe({}, function() {
|
||||
ipm2.disconnect();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should fork PM2', function(done) {
|
||||
try {
|
||||
pm2 = APPS.forkPM2();
|
||||
} catch(e) {
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
describe('Interface', function() {
|
||||
|
||||
beforeEach(function(done) {
|
||||
ipm2 = Ipm2();
|
||||
|
||||
ipm2.once('ready', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
ipm2.disconnect();
|
||||
});
|
||||
|
||||
it('should IPM2 have the right properties', function(done) {
|
||||
ipm2.bus.should.exist;
|
||||
ipm2.rpc.should.have.properties([
|
||||
'restartProcessId',
|
||||
'prepare',
|
||||
'prepareJson',
|
||||
'ping',
|
||||
'reloadLogs',
|
||||
'stopAll',
|
||||
'stopProcessId'
|
||||
//..
|
||||
]);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should start a process via IPM2', function(done) {
|
||||
APPS.launchApp(ipm2, 'echo.js', 'echo', function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(1);
|
||||
procs[0].pm2_env.status.should.eql('online');
|
||||
procs[0].pm2_env.should.have.properties([
|
||||
'pm_id',
|
||||
'restart_time',
|
||||
'created_at',
|
||||
'pm_uptime',
|
||||
'pm_exec_path',
|
||||
'pm_err_log_path',
|
||||
'pm_out_log_path',
|
||||
'pm_pid_path'
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should receive log:out and log:err messages', function(done) {
|
||||
var plan = new Plan(2, done);
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} data
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, data) {
|
||||
if (event == 'log:out')
|
||||
plan.ok(true);
|
||||
if (event == 'log:err')
|
||||
plan.ok(true);
|
||||
}
|
||||
|
||||
ipm2.bus.on('*', rcpt);
|
||||
});
|
||||
|
||||
it('should receive process:exit and process:online signal on restart', function(done) {
|
||||
var plan = new Plan(3, done);
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} data
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, data) {
|
||||
if (event == 'process:exit')
|
||||
plan.ok(true);
|
||||
if (event == 'process:online')
|
||||
plan.ok(true);
|
||||
}
|
||||
|
||||
ipm2.bus.on('*', rcpt);
|
||||
|
||||
ipm2.rpc.restartProcessName('echo', function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs[0].pm2_env.restart_time.should.eql(1);
|
||||
plan.ok(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete echo process', function(done) {
|
||||
ipm2.rpc.deleteProcessName('echo', function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should start exception process', function(done) {
|
||||
APPS.launchApp(ipm2, 'throw.js', 'throw', function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(1);
|
||||
procs[0].pm2_env.status.should.eql('online');
|
||||
procs[0].pm2_env.should.have.properties([
|
||||
'pm_id',
|
||||
'restart_time',
|
||||
'created_at',
|
||||
'pm_uptime',
|
||||
'pm_exec_path',
|
||||
'pm_err_log_path',
|
||||
'pm_out_log_path',
|
||||
'pm_pid_path'
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should receive process:exception message', function(done) {
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} data
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, data) {
|
||||
if (event == 'process:exception')
|
||||
done();
|
||||
}
|
||||
|
||||
ipm2.bus.on('*', rcpt);
|
||||
});
|
||||
|
||||
it('should delete throwing exception when calling stop method', function(done) {
|
||||
ipm2.rpc.stopProcessName('throw', function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(1);
|
||||
procs[0].pm2_env.status.should.eql('stopped');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete all processes', function(done) {
|
||||
ipm2.rpc.deleteAll({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should no processes be present in pm2 db', function(done) {
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Specific events in CLUSTER_MODE', function() {
|
||||
beforeEach(function(done) {
|
||||
ipm2 = Ipm2();
|
||||
|
||||
ipm2.once('ready', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
ipm2.rpc.deleteAll({}, function(err, procs) {
|
||||
ipm2.disconnect();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should start process own_event and catch custom event', function(done) {
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} data
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, data) {
|
||||
if (event == 'user:register')
|
||||
done();
|
||||
}
|
||||
|
||||
APPS.launchApp(ipm2, 'events/own_event.js', 'own_event', function(err, proc) {
|
||||
should(err).be.null;
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(1);
|
||||
ipm2.bus.on('*', rcpt);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should start process own_event and catch custom event', function(done) {
|
||||
var plan = new Plan(3, done);
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method triggerMessage
|
||||
* @return
|
||||
*/
|
||||
function triggerMessage() {
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(1);
|
||||
console.log('Triggering message');
|
||||
ipm2.rpc.msgProcess({
|
||||
id : procs[0].pm_id,
|
||||
msg : 'refresh:db'
|
||||
}, function(err, dt) {
|
||||
should(err).be.null;
|
||||
console.log('Message triggered');
|
||||
plan.ok(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} msg
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, msg) {
|
||||
// This is the message that a new action will be registered
|
||||
if (event == 'axm:action') {
|
||||
msg.data.type.should.be.eql('axm:action');
|
||||
msg.data.data.action_name.should.eql('refresh:db');
|
||||
msg.process.should.have.properties([
|
||||
'process', 'pm2_env'
|
||||
]);
|
||||
plan.ok(true);
|
||||
triggerMessage();
|
||||
}
|
||||
|
||||
if (event == 'axm:reply') {
|
||||
msg.data.type.should.eql('axm:reply');
|
||||
msg.data.data.success.should.eql(true);
|
||||
msg.process.should.have.properties([
|
||||
'process', 'pm2_env'
|
||||
]);
|
||||
plan.ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
ipm2.bus.on('*', rcpt);
|
||||
|
||||
APPS.launchApp(ipm2, 'events/custom_action.js', 'custom_event', function(err, proc) {
|
||||
should(err).be.null;
|
||||
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip('Specific event in FORK_MODE', function() {
|
||||
beforeEach(function(done) {
|
||||
ipm2 = Ipm2();
|
||||
|
||||
ipm2.once('ready', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
ipm2.disconnect();
|
||||
done();
|
||||
});
|
||||
|
||||
it('should start process own_event and catch custom event', function(done) {
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} data
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, data) {
|
||||
if (event == 'user:register')
|
||||
done();
|
||||
}
|
||||
|
||||
APPS.launchAppFork(ipm2, 'events/own_event.js', 'own_event', function(err, proc) {
|
||||
should(err).be.null;
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
ipm2.bus.on('*', rcpt);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete all apps', function(done) {
|
||||
ipm2.rpc.deleteAll({}, function(err, procs) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should start process own_event and catch custom event', function(done) {
|
||||
var plan = new Plan(3, done);
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method triggerMessage
|
||||
* @return
|
||||
*/
|
||||
function triggerMessage() {
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
console.log('Triggering message');
|
||||
ipm2.rpc.msgProcess({
|
||||
id : procs[0].pm_id,
|
||||
msg : 'refresh:db'
|
||||
}, function(err, dt) {
|
||||
should(err).be.null;
|
||||
console.log('Message triggered');
|
||||
plan.ok(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} msg
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, msg) {
|
||||
// This is the message that a new action will be registered
|
||||
if (event == 'axm:action') {
|
||||
msg.data.type.should.be.eql('axm:action');
|
||||
msg.data.data.action_name.should.eql('refresh:db');
|
||||
msg.process.should.have.properties([
|
||||
'process', 'pm2_env'
|
||||
]);
|
||||
plan.ok(true);
|
||||
triggerMessage();
|
||||
}
|
||||
|
||||
if (event == 'axm:reply') {
|
||||
msg.data.type.should.eql('axm:reply');
|
||||
msg.data.data.success.should.eql(true);
|
||||
msg.process.should.have.properties([
|
||||
'process', 'pm2_env'
|
||||
]);
|
||||
plan.ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
ipm2.bus.on('*', rcpt);
|
||||
|
||||
APPS.launchAppFork(ipm2, 'events/custom_action.js', 'custom_event', function(err, proc) {
|
||||
should(err).be.null;
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs.length.should.eql(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should reference the new action into the pm2_env.axm_actions', function(done) {
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs[0].pm2_env.axm_actions[0].action_name.should.eql('refresh:db');
|
||||
should(procs[0].pm2_env.axm_actions[0].opts).be.null;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should on process stop not referenciate axm_actions anymore', function(done) {
|
||||
ipm2.rpc.stopAll({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs[0].pm2_env.axm_actions.length.should.eql(0);;
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should start an APP and reference axm_action once axm:action message received', function(done) {
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} msg
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, msg) {
|
||||
// This is the message that a new action will be registered
|
||||
if (event == 'axm:action') {
|
||||
ipm2.rpc.getMonitorData({}, function(err, procs) {
|
||||
should(err).be.null;
|
||||
procs[1].pm2_env.axm_actions[0].action_name.should.eql('refresh:db');
|
||||
should(procs[1].pm2_env.axm_actions[0].opts).be.null;
|
||||
done();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
APPS.launchAppFork(ipm2, 'events/custom_action.js', 'custom_event', function(err, procs) {
|
||||
should(err).be.null;
|
||||
ipm2.bus.on('*', rcpt);
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete all apps', function(done) {
|
||||
ipm2.rpc.deleteAll({}, function(err, procs) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe.skip('Multiple axm_actions test', function() {
|
||||
beforeEach(function(done) {
|
||||
ipm2 = Ipm2();
|
||||
|
||||
ipm2.once('ready', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
ipm2.disconnect();
|
||||
done();
|
||||
});
|
||||
|
||||
it('should start process in cluster_mode and get 3 axm:action + get comments', function(done) {
|
||||
var plan = new Plan(6, done);
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method rcpt
|
||||
* @param {} event
|
||||
* @param {} msg
|
||||
* @return
|
||||
*/
|
||||
function rcpt(event, msg) {
|
||||
if (event == 'axm:action') {
|
||||
plan.ok(true);
|
||||
if (msg.data.data.opts && msg.data.data.opts.comment) {
|
||||
plan.ok(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
ipm2.bus.on('*', rcpt);
|
||||
|
||||
APPS.launchAppFork(ipm2, 'events/custom_action_with_params.js', 'custom_action_params', function(err, procs) {
|
||||
should(err).be.null;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@ -43,21 +43,7 @@ describe('Satan', function() {
|
||||
Satan.should.have.property('killDaemon');
|
||||
});
|
||||
|
||||
|
||||
describe('DAEMON', function() {
|
||||
it.skip('should have the right exposed methods via RPC', function(done) {
|
||||
Satan.getExposedMethods(function(err, methods) {
|
||||
assert(err == null);
|
||||
methods.should.have.property('prepare');
|
||||
methods.should.have.property('getMonitorData');
|
||||
methods.should.have.property('getSystemData');
|
||||
methods.should.have.property('stopProcessId');
|
||||
methods.should.have.property('stopAll');
|
||||
methods.should.have.property('killMe');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get an empty process list', function(done) {
|
||||
Satan.executeRemote('getMonitorData', {}, function(err, res) {
|
||||
assert(res.length === 0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user