v1.18.x
Julian Lam 8 years ago
parent 5a55c882ab
commit 29e868b002

@ -90,6 +90,11 @@ if (nconf.get('setup') || nconf.get('install')) {
listPlugins();
} else if (nconf.get('build')) {
require('./src/meta/build').build(nconf.get('build'));
} else if (nconf.get('events')) {
async.series([
async.apply(require('./src/database').init),
async.apply(require('./src/events').output),
]);
} else {
require('./src/start').start();
}
@ -218,6 +223,7 @@ function upgrade() {
function activate() {
var db = require('./src/database');
var plugins = require('./src/plugins');
var events = require('./src/events');
var plugin = nconf.get('activate');
async.waterfall([
function (next) {
@ -238,6 +244,12 @@ function activate() {
winston.info('Activating plugin `%s`', plugin);
db.sortedSetAdd('plugins:active', 0, plugin, next);
},
function (next) {
events.log({
type: 'plugin-activate',
text: plugin,
}, next);
},
], function (err) {
if (err) {
winston.error(err.message);

@ -495,6 +495,13 @@ var commands = {
upgradePlugins();
},
},
events: {
description: 'Outputs the last ten (10) administrative events recorded by NodeBB',
usage: 'Usage: ' + './nodebb events'.yellow,
handler: function () {
fork(['--events']);
},
},
help: {
description: 'Display the help message for a given command',
usage: 'Usage: ' + './nodebb help <command>'.yellow,

@ -138,3 +138,19 @@ events.deleteAll = function (callback) {
events.deleteEvents(eids, next);
}, { alwaysStartAt: 0 }, callback);
};
events.output = function () {
process.stdout.write('\nDisplaying last ten administrative events...\n'.bold);
events.getEvents(0, 9, function (err, events) {
if (err) {
process.stdout.write(' Error '.red + String(err.message).reset);
process.exit(1);
}
events.forEach(function (event) {
process.stdout.write(' * ' + String(event.timestampISO).green + ' ' + String(event.type).yellow + (event.text ? ' ' + event.text : '') + ' (uid: '.reset + (event.uid ? event.uid : 0) + ')\n');
});
process.exit(0);
});
};

@ -10,7 +10,7 @@ var os = require('os');
var db = require('../database');
var meta = require('../meta');
var pubsub = require('../pubsub');
var events = require('../events');
module.exports = function (Plugins) {
if (nconf.get('isPrimary') === 'true') {
@ -52,6 +52,12 @@ module.exports = function (Plugins) {
Plugins.fireHook(isActive ? 'action:plugin.deactivate' : 'action:plugin.activate', { id: id });
setImmediate(next);
},
function (next) {
events.log({
type: 'plugin-' + (isActive ? 'deactivate' : 'activate'),
text: id,
}, next);
},
], function (err) {
if (err) {
winston.warn('[plugins] Could not toggle active state on plugin \'' + id + '\'');

@ -6,6 +6,7 @@ var winston = require('winston');
var nconf = require('nconf');
var async = require('async');
var db = require('./database');
var events = require('./events');
var Reset = {};
@ -133,6 +134,12 @@ function resetPlugin(pluginId, callback) {
next();
}
},
function (next) {
events.log({
type: 'plugin-deactivate',
text: pluginId,
}, next);
},
], function (err) {
if (err) {
winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err.message);

Loading…
Cancel
Save