mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-16 21:40:23 +01:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1943f8fdfa | ||
|
|
6ae0ca17d7 | ||
|
|
727010822d | ||
|
|
a1bf407cd4 | ||
|
|
a96eb0c2a4 | ||
|
|
5ddbffb083 | ||
|
|
f740a2d958 | ||
|
|
7c77c8cfc6 | ||
|
|
f19871f311 | ||
|
|
50191a38b3 | ||
|
|
37f1f94bed | ||
|
|
4cdb3a34d2 | ||
|
|
cce076fc83 | ||
|
|
0a73fade08 |
43
loader.js
43
loader.js
@@ -161,14 +161,12 @@ Loader.addClusterEvents = function(callback) {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[cluster] Child Process (' + worker.process.pid + ') has exited (code: ' + code + ')');
|
||||
console.log('[cluster] Child Process (' + worker.process.pid + ') has exited (code: ' + code + ', signal: ' + signal +')');
|
||||
if (!worker.suicide) {
|
||||
console.log('[cluster] Spinning up another process...');
|
||||
|
||||
var wasPrimary = parseInt(worker.id, 10) === Loader.primaryWorker;
|
||||
cluster.fork({
|
||||
handle_jobs: wasPrimary
|
||||
});
|
||||
forkWorker(wasPrimary);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -177,30 +175,33 @@ Loader.addClusterEvents = function(callback) {
|
||||
});
|
||||
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
Loader.start = function(callback) {
|
||||
var output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true }),
|
||||
worker;
|
||||
|
||||
console.log('Clustering enabled: Spinning up ' + numProcs + ' process(es).\n');
|
||||
|
||||
for(var x=0;x<numProcs;x++) {
|
||||
// Only the first worker sets up templates/sounds/jobs/etc
|
||||
worker = cluster.fork({
|
||||
cluster_setup: x === 0,
|
||||
handle_jobs: x === 0
|
||||
});
|
||||
|
||||
// Logging
|
||||
if (silent) {
|
||||
worker.process.stdout.pipe(output);
|
||||
}
|
||||
for(var x=0; x<numProcs; ++x) {
|
||||
forkWorker(x === 0);
|
||||
}
|
||||
|
||||
if (callback) callback();
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
function forkWorker(isPrimary) {
|
||||
var worker = cluster.fork({
|
||||
cluster_setup: isPrimary,
|
||||
handle_jobs: isPrimary
|
||||
}),
|
||||
output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true });
|
||||
|
||||
if (silent) {
|
||||
worker.process.stdout.pipe(output);
|
||||
worker.process.stderr.pipe(output);
|
||||
}
|
||||
}
|
||||
|
||||
Loader.restart = function(callback) {
|
||||
// Slate existing workers for termination -- welcome to death row.
|
||||
Loader.shutdown_queue = Loader.shutdown_queue.concat(Object.keys(cluster.workers));
|
||||
@@ -219,7 +220,7 @@ Loader.notifyWorkers = function (msg) {
|
||||
Object.keys(cluster.workers).forEach(function(id) {
|
||||
cluster.workers[id].send(msg);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
nconf.argv().file({
|
||||
|
||||
2
nodebb
2
nodebb
@@ -29,7 +29,7 @@ case "$1" in
|
||||
echo " \"./nodebb log\" to view server output";
|
||||
|
||||
# Start the loader daemon
|
||||
"$node" loader -d "$@"
|
||||
"$node" loader "$@"
|
||||
;;
|
||||
|
||||
stop)
|
||||
|
||||
2430
npm-shrinkwrap.json
generated
Normal file
2430
npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
"name": "nodebb",
|
||||
"license": "GPLv3 or later",
|
||||
"description": "NodeBB Forum",
|
||||
"version": "0.5.3-dev",
|
||||
"version": "0.5.4",
|
||||
"homepage": "http://www.nodebb.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -33,35 +33,16 @@ define('admin/extend/plugins', function() {
|
||||
pluginsList.on('click', 'button[data-action="toggleInstall"]', function() {
|
||||
pluginID = $(this).parents('li').attr('data-plugin-id');
|
||||
|
||||
var btn = $(this);
|
||||
var activateBtn = btn.siblings('[data-action="toggleActive"]');
|
||||
btn.html(btn.html() + 'ing')
|
||||
.attr('disabled', true)
|
||||
.find('i').attr('class', 'fa fa-refresh fa-spin');
|
||||
|
||||
socket.emit('admin.plugins.toggleInstall', pluginID, function(err, status) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
if (status.installed) {
|
||||
btn.html('<i class="fa fa-trash-o"></i> Uninstall');
|
||||
Plugins.suggest(pluginID, function(err, payload) {
|
||||
if (!err) {
|
||||
Plugins.toggleInstall(pluginID, payload.version);
|
||||
} else {
|
||||
btn.html('<i class="fa fa-download"></i> Install');
|
||||
|
||||
bootbox.confirm('<p>NodeBB could not reach the package manager, proceed with installation of latest version?</p><div class="alert alert-danger"><strong>Server returned (' + err.status + ')</strong>: ' + err.responseText + '</div>', function(confirm) {
|
||||
if (confirm) {
|
||||
Plugins.toggleInstall(pluginID, 'latest');
|
||||
}
|
||||
});
|
||||
}
|
||||
activateBtn.toggleClass('hidden', !status.installed);
|
||||
|
||||
btn.toggleClass('btn-danger', status.installed).toggleClass('btn-success', !status.installed)
|
||||
.attr('disabled', false);
|
||||
|
||||
app.alert({
|
||||
alert_id: 'plugin_toggled',
|
||||
title: 'Plugin ' + (status.installed ? 'Installed' : 'Uninstalled'),
|
||||
message: status.installed ? 'Plugin successfully installed, please activate the plugin.' : 'The plugin has been successfully deactivated and uninstalled.',
|
||||
type: 'info',
|
||||
timeout: 5000
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -70,15 +51,30 @@ define('admin/extend/plugins', function() {
|
||||
var parent = btn.parents('li');
|
||||
pluginID = parent.attr('data-plugin-id');
|
||||
|
||||
btn.attr('disabled', true).find('i').attr('class', 'fa fa-refresh fa-spin');
|
||||
|
||||
socket.emit('admin.plugins.upgrade', pluginID, function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
Plugins.suggest(pluginID, function(err, payload) {
|
||||
if (!err) {
|
||||
require(['semver'], function(semver) {
|
||||
if (payload.version === 'latest' || semver.gt(payload.version, parent.find('.currentVersion').text())) {
|
||||
btn.attr('disabled', true).find('i').attr('class', 'fa fa-refresh fa-spin');
|
||||
socket.emit('admin.plugins.upgrade', {
|
||||
id: pluginID,
|
||||
version: payload.version
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
parent.find('.fa-exclamation-triangle').remove();
|
||||
parent.find('.currentVersion').text(payload.version);
|
||||
btn.remove();
|
||||
});
|
||||
} else {
|
||||
bootbox.alert('<p>Your version of NodeBB (v' + app.config.version + ') is only cleared to upgrade to v' + payload.version + ' of this plugin. Please update your NodeBB if you wish to install a newer version of this plugin.');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bootbox.alert('<p>NodeBB could not reach the package manager, an upgrade is not suggested at this time.</p>');
|
||||
}
|
||||
parent.find('.fa-exclamation-triangle').remove();
|
||||
parent.find('.currentVersion').text(parent.find('.latestVersion').text());
|
||||
btn.remove();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -94,6 +90,58 @@ define('admin/extend/plugins', function() {
|
||||
} else {
|
||||
pluginsList.append('<li><p><i>No plugins found.</i></p></li>');
|
||||
}
|
||||
},
|
||||
toggleInstall: function(pluginID, version, callback) {
|
||||
var btn = $('li[data-plugin-id="' + pluginID + '"] button[data-action="toggleInstall"]');
|
||||
var activateBtn = btn.siblings('[data-action="toggleActive"]');
|
||||
btn.html(btn.html() + 'ing')
|
||||
.attr('disabled', true)
|
||||
.find('i').attr('class', 'fa fa-refresh fa-spin');
|
||||
|
||||
socket.emit('admin.plugins.toggleInstall', {
|
||||
id: pluginID,
|
||||
version: version
|
||||
}, function(err, status) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
if (status.installed) {
|
||||
btn.html('<i class="fa fa-trash-o"></i> Uninstall');
|
||||
} else {
|
||||
btn.html('<i class="fa fa-download"></i> Install');
|
||||
|
||||
}
|
||||
activateBtn.toggleClass('hidden', !status.installed);
|
||||
|
||||
btn.toggleClass('btn-danger', status.installed).toggleClass('btn-success', !status.installed)
|
||||
.attr('disabled', false);
|
||||
|
||||
app.alert({
|
||||
alert_id: 'plugin_toggled',
|
||||
title: 'Plugin ' + (status.installed ? 'Installed' : 'Uninstalled'),
|
||||
message: status.installed ? 'Plugin successfully installed, please activate the plugin.' : 'The plugin has been successfully deactivated and uninstalled.',
|
||||
type: 'info',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
},
|
||||
suggest: function(pluginId, callback) {
|
||||
var nbbVersion = app.config.version;
|
||||
$.ajax('https://packages.nodebb.org/api/v1/suggest', {
|
||||
type: 'GET',
|
||||
data: {
|
||||
package: pluginId,
|
||||
version: nbbVersion
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function(payload) {
|
||||
callback(undefined, payload);
|
||||
}).fail(callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -136,11 +136,18 @@ function getUserDataByUserSlug(userslug, callerUID, callback) {
|
||||
accountsController.getUserByUID = function(req, res, next) {
|
||||
var uid = req.params.uid ? req.params.uid : 0;
|
||||
|
||||
user.getUserData(uid, function(err, userData) {
|
||||
async.parallel({
|
||||
settings: async.apply(user.getSettings, uid),
|
||||
userData: async.apply(user.getUserData, uid)
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.json(userData);
|
||||
|
||||
results.userData.email = results.settings.showemail ? results.userData.email : undefined;
|
||||
results.userData.fullname = results.settings.showfullname ? results.userData.fullname : undefined;
|
||||
|
||||
res.json(results.userData);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ var async = require('async'),
|
||||
db.rename('group:' + oldName, 'group:' + newName, next);
|
||||
},
|
||||
function(next) {
|
||||
Groups.exists('group:' + oldName + ':members', function(err, exists) {
|
||||
db.exists('group:' + oldName + ':members', function(err, exists) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
'use strict';
|
||||
|
||||
var winston = require('winston'),
|
||||
db = require('../database');
|
||||
db = require('../database'),
|
||||
pkg = require('../../package.json');
|
||||
|
||||
module.exports = function(Meta) {
|
||||
|
||||
@@ -25,7 +26,9 @@ module.exports = function(Meta) {
|
||||
|
||||
Meta.configs.list = function (callback) {
|
||||
db.getObject('config', function (err, config) {
|
||||
callback(err, config || {});
|
||||
config = config || {};
|
||||
config.version = pkg.version;
|
||||
callback(err, config);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -550,7 +550,7 @@ var fs = require('fs'),
|
||||
});
|
||||
};
|
||||
|
||||
Plugins.toggleInstall = function(id, callback) {
|
||||
Plugins.toggleInstall = function(id, version, callback) {
|
||||
Plugins.isInstalled(id, function(err, installed) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -573,7 +573,7 @@ var fs = require('fs'),
|
||||
npm.load({}, next);
|
||||
},
|
||||
function(res, next) {
|
||||
npm.commands[installed ? 'uninstall' : 'install'](installed ? id : [id], next);
|
||||
npm.commands[installed ? 'uninstall' : 'install'](installed ? id : [id + '@' + (version || 'latest')], next);
|
||||
}
|
||||
], function(err) {
|
||||
callback(err, {
|
||||
@@ -584,13 +584,13 @@ var fs = require('fs'),
|
||||
});
|
||||
};
|
||||
|
||||
Plugins.upgrade = function(id, callback) {
|
||||
Plugins.upgrade = function(id, version, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
npm.load({}, next);
|
||||
},
|
||||
function(res, next) {
|
||||
npm.commands.install([id], next);
|
||||
npm.commands.install([id + '@' + (version || 'latest')], next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -94,12 +94,12 @@ SocketAdmin.plugins.toggleActive = function(socket, plugin_id, callback) {
|
||||
plugins.toggleActive(plugin_id, callback);
|
||||
};
|
||||
|
||||
SocketAdmin.plugins.toggleInstall = function(socket, plugin_id, callback) {
|
||||
plugins.toggleInstall(plugin_id, callback);
|
||||
SocketAdmin.plugins.toggleInstall = function(socket, data, callback) {
|
||||
plugins.toggleInstall(data.id, data.version, callback);
|
||||
};
|
||||
|
||||
SocketAdmin.plugins.upgrade = function(socket, plugin_id, callback) {
|
||||
plugins.upgrade(plugin_id, callback);
|
||||
SocketAdmin.plugins.upgrade = function(socket, data, callback) {
|
||||
plugins.upgrade(data.id, data.version, callback);
|
||||
};
|
||||
|
||||
SocketAdmin.widgets.set = function(socket, data, callback) {
|
||||
|
||||
@@ -104,7 +104,7 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
if (user.password) {
|
||||
user.password = null;
|
||||
user.password = undefined;
|
||||
}
|
||||
|
||||
if (!parseInt(user.uid, 10)) {
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = function(User) {
|
||||
return winston.log('[user/jobs] Did not send daily digests because subscription system is disabled.');
|
||||
}
|
||||
|
||||
topics.getLatestTopics(0, 0, 10, 'day', function(err, topics) {
|
||||
topics.getLatestTopics(0, 0, 10, 'day', function(err, data) {
|
||||
if (err) {
|
||||
return winston.error('[user/jobs] Could not send daily digests: ' + err.message);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ module.exports = function(User) {
|
||||
return next();
|
||||
}
|
||||
|
||||
sendEmails(subscribed, topics, next);
|
||||
sendEmails(subscribed, data.topics, next);
|
||||
});
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
"^users/latest": "users",
|
||||
"^users/sort-reputation": "users",
|
||||
"^users/search": "users",
|
||||
"^user.*edit": "account/edit",
|
||||
"^user.*following": "account/following",
|
||||
"^user.*followers": "account/followers",
|
||||
"^user.*settings": "account/settings",
|
||||
"^user.*favourites": "account/favourites",
|
||||
"^user.*posts": "account/posts",
|
||||
"^user.*topics": "account/topics",
|
||||
"^user/.*/edit": "account/edit",
|
||||
"^user/.*/following": "account/following",
|
||||
"^user/.*/followers": "account/followers",
|
||||
"^user/.*/settings": "account/settings",
|
||||
"^user/.*/favourites": "account/favourites",
|
||||
"^user/.*/posts": "account/posts",
|
||||
"^user/.*/topics": "account/topics",
|
||||
"^user/.*": "account/profile",
|
||||
"^reset/.*": "reset_code",
|
||||
"^tags/.*": "tag",
|
||||
|
||||
Reference in New Issue
Block a user