mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
closes #5585
This commit is contained in:
12
app.js
12
app.js
@@ -90,6 +90,11 @@ if (nconf.get('setup') || nconf.get('install')) {
|
|||||||
listPlugins();
|
listPlugins();
|
||||||
} else if (nconf.get('build')) {
|
} else if (nconf.get('build')) {
|
||||||
require('./src/meta/build').build(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 {
|
} else {
|
||||||
require('./src/start').start();
|
require('./src/start').start();
|
||||||
}
|
}
|
||||||
@@ -218,6 +223,7 @@ function upgrade() {
|
|||||||
function activate() {
|
function activate() {
|
||||||
var db = require('./src/database');
|
var db = require('./src/database');
|
||||||
var plugins = require('./src/plugins');
|
var plugins = require('./src/plugins');
|
||||||
|
var events = require('./src/events');
|
||||||
var plugin = nconf.get('activate');
|
var plugin = nconf.get('activate');
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
@@ -238,6 +244,12 @@ function activate() {
|
|||||||
winston.info('Activating plugin `%s`', plugin);
|
winston.info('Activating plugin `%s`', plugin);
|
||||||
db.sortedSetAdd('plugins:active', 0, plugin, next);
|
db.sortedSetAdd('plugins:active', 0, plugin, next);
|
||||||
},
|
},
|
||||||
|
function (next) {
|
||||||
|
events.log({
|
||||||
|
type: 'plugin-activate',
|
||||||
|
text: plugin,
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
], function (err) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error(err.message);
|
winston.error(err.message);
|
||||||
|
|||||||
7
nodebb
7
nodebb
@@ -495,6 +495,13 @@ var commands = {
|
|||||||
upgradePlugins();
|
upgradePlugins();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
events: {
|
||||||
|
description: 'Outputs the last ten (10) administrative events recorded by NodeBB',
|
||||||
|
usage: 'Usage: ' + './nodebb events'.yellow,
|
||||||
|
handler: function () {
|
||||||
|
fork(['--events']);
|
||||||
|
},
|
||||||
|
},
|
||||||
help: {
|
help: {
|
||||||
description: 'Display the help message for a given command',
|
description: 'Display the help message for a given command',
|
||||||
usage: 'Usage: ' + './nodebb help <command>'.yellow,
|
usage: 'Usage: ' + './nodebb help <command>'.yellow,
|
||||||
|
|||||||
@@ -138,3 +138,19 @@ events.deleteAll = function (callback) {
|
|||||||
events.deleteEvents(eids, next);
|
events.deleteEvents(eids, next);
|
||||||
}, { alwaysStartAt: 0 }, callback);
|
}, { 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 db = require('../database');
|
||||||
var meta = require('../meta');
|
var meta = require('../meta');
|
||||||
var pubsub = require('../pubsub');
|
var pubsub = require('../pubsub');
|
||||||
|
var events = require('../events');
|
||||||
|
|
||||||
module.exports = function (Plugins) {
|
module.exports = function (Plugins) {
|
||||||
if (nconf.get('isPrimary') === 'true') {
|
if (nconf.get('isPrimary') === 'true') {
|
||||||
@@ -52,6 +52,12 @@ module.exports = function (Plugins) {
|
|||||||
Plugins.fireHook(isActive ? 'action:plugin.deactivate' : 'action:plugin.activate', { id: id });
|
Plugins.fireHook(isActive ? 'action:plugin.deactivate' : 'action:plugin.activate', { id: id });
|
||||||
setImmediate(next);
|
setImmediate(next);
|
||||||
},
|
},
|
||||||
|
function (next) {
|
||||||
|
events.log({
|
||||||
|
type: 'plugin-' + (isActive ? 'deactivate' : 'activate'),
|
||||||
|
text: id,
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
], function (err) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.warn('[plugins] Could not toggle active state on plugin \'' + id + '\'');
|
winston.warn('[plugins] Could not toggle active state on plugin \'' + id + '\'');
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var winston = require('winston');
|
|||||||
var nconf = require('nconf');
|
var nconf = require('nconf');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var db = require('./database');
|
var db = require('./database');
|
||||||
|
var events = require('./events');
|
||||||
|
|
||||||
var Reset = {};
|
var Reset = {};
|
||||||
|
|
||||||
@@ -133,6 +134,12 @@ function resetPlugin(pluginId, callback) {
|
|||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
function (next) {
|
||||||
|
events.log({
|
||||||
|
type: 'plugin-deactivate',
|
||||||
|
text: pluginId,
|
||||||
|
}, next);
|
||||||
|
},
|
||||||
], function (err) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err.message);
|
winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user