mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 19:36:41 +02:00
re: #5211, bringing back the RELOAD BUTTON :rage2:
This commit is contained in:
@@ -124,6 +124,16 @@
|
||||
}
|
||||
|
||||
function setupRestartLinks() {
|
||||
$('.reload').off('click').on('click', function () {
|
||||
bootbox.confirm('Are you sure you wish to reload NodeBB?', function (confirm) {
|
||||
if (confirm) {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.restart').off('click').on('click', function () {
|
||||
bootbox.confirm('Are you sure you wish to restart NodeBB?', function (confirm) {
|
||||
if (confirm) {
|
||||
@@ -133,13 +143,7 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.reload').off('click').on('click', function () {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.reload();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function launchSnackbar(params) {
|
||||
var message = (params.title ? "<strong>" + params.title + "</strong>" : '') + (params.message ? params.message : '');
|
||||
@@ -148,7 +152,7 @@
|
||||
translator.translate(message, function (html) {
|
||||
var bar = $.snackbar({
|
||||
content: html,
|
||||
timeout: 3000,
|
||||
timeout: params.timeout || 3000,
|
||||
htmlAllowed: true
|
||||
});
|
||||
|
||||
|
||||
@@ -14,45 +14,12 @@ define('admin/modules/instance', function () {
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
socket.emit('admin.reload', function (err) {
|
||||
if (!err) {
|
||||
app.alert({
|
||||
alert_id: 'instance_reload',
|
||||
type: 'success',
|
||||
title: '<i class="fa fa-check"></i> Success',
|
||||
message: 'NodeBB has successfully reloaded.',
|
||||
timeout: 5000
|
||||
});
|
||||
} else {
|
||||
app.alert({
|
||||
alert_id: 'instance_reload',
|
||||
type: 'danger',
|
||||
title: '[[global:alert.error]]',
|
||||
message: '[[error:reload-failed, ' + err.message + ']]'
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
instance.restart = function (callback) {
|
||||
app.alert({
|
||||
alert_id: 'instance_restart',
|
||||
type: 'info',
|
||||
title: 'Restarting... <i class="fa fa-spin fa-refresh"></i>',
|
||||
message: 'NodeBB is restarting.',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
$(window).one('action:reconnected', function () {
|
||||
app.alert({
|
||||
alert_id: 'instance_restart',
|
||||
alert_id: 'instance_reload',
|
||||
type: 'success',
|
||||
title: '<i class="fa fa-check"></i> Success',
|
||||
message: 'NodeBB has successfully restarted.',
|
||||
message: 'NodeBB has reloaded successfully.',
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
@@ -61,7 +28,41 @@ define('admin/modules/instance', function () {
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('admin.restart');
|
||||
socket.emit('admin.reload');
|
||||
};
|
||||
|
||||
instance.restart = function (callback) {
|
||||
app.alert({
|
||||
alert_id: 'instance_restart',
|
||||
type: 'info',
|
||||
title: 'Rebuilding... <i class="fa fa-spin fa-refresh"></i>',
|
||||
message: 'NodeBB is rebiulding front-end assets (css, javascript, etc).',
|
||||
timeout: 10000
|
||||
});
|
||||
|
||||
$(window).one('action:reconnected', function () {
|
||||
app.alert({
|
||||
alert_id: 'instance_restart',
|
||||
type: 'success',
|
||||
title: '<i class="fa fa-check"></i> Success',
|
||||
message: 'NodeBB has successfully restarted.',
|
||||
timeout: 10000
|
||||
});
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('admin.restart', function () {
|
||||
app.alert({
|
||||
alert_id: 'instance_restart',
|
||||
type: 'info',
|
||||
title: 'Build Complete!... <i class="fa fa-spin fa-refresh"></i>',
|
||||
message: 'NodeBB is reloading.',
|
||||
timeout: 10000
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return instance;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
var async = require('async');
|
||||
var winston = require('winston');
|
||||
var nconf = require('nconf');
|
||||
var path = require('path');
|
||||
|
||||
var meta = require('../meta');
|
||||
var plugins = require('../plugins');
|
||||
@@ -49,7 +50,7 @@ SocketAdmin.before = function (socket, method, data, next) {
|
||||
});
|
||||
};
|
||||
|
||||
SocketAdmin.restart = function (socket, data, callback) {
|
||||
SocketAdmin.reload = function (socket, data, callback) {
|
||||
events.log({
|
||||
type: 'restart',
|
||||
uid: socket.uid,
|
||||
@@ -57,12 +58,33 @@ SocketAdmin.restart = function (socket, data, callback) {
|
||||
});
|
||||
meta.restart();
|
||||
callback();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload deprecated as of v1.1.2+, remove in v2.x
|
||||
*/
|
||||
SocketAdmin.reload = SocketAdmin.restart;
|
||||
SocketAdmin.restart = function (socket, data, callback) {
|
||||
// Rebuild assets and reload NodeBB
|
||||
var child_process = require('child_process');
|
||||
var build_worker = child_process.fork('app.js', ['--build'], {
|
||||
cwd: path.join(__dirname, '../../'),
|
||||
stdio: 'pipe'
|
||||
});
|
||||
|
||||
build_worker.on('exit', function() {
|
||||
events.log({
|
||||
type: 'build',
|
||||
uid: socket.uid,
|
||||
ip: socket.ip
|
||||
});
|
||||
|
||||
events.log({
|
||||
type: 'restart',
|
||||
uid: socket.uid,
|
||||
ip: socket.ip
|
||||
});
|
||||
|
||||
meta.restart();
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
SocketAdmin.fireEvent = function (socket, data, callback) {
|
||||
index.server.emit(data.name, data.payload || {});
|
||||
|
||||
@@ -95,7 +95,13 @@
|
||||
<div class="panel-heading">System Control</div>
|
||||
<div class="panel-body text-center">
|
||||
<p>
|
||||
<button class="btn btn-danger btn-block restart" data-placement="bottom" data-toggle="tooltip" title="Restarting NodeBB will drop all existing connections for a few seconds">Restart</button>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-warning reload">Reload</button>
|
||||
<button class="btn btn-danger restart">Restart</button>
|
||||
</div>
|
||||
</p>
|
||||
<p class="help-block">
|
||||
Reloading or Restarting your NodeBB will drop all existing connections for a few seconds.
|
||||
</p>
|
||||
<p>
|
||||
<a href="{config.relative_path}/admin/settings/advanced" class="btn btn-info btn-block" data-placement="bottom" data-toggle="tooltip" title="Click here to set up maintenance mode for NodeBB">Maintenance Mode</a>
|
||||
|
||||
@@ -122,6 +122,11 @@
|
||||
<i class="fa fa-fw fa-ellipsis-v"></i>
|
||||
</a>
|
||||
<ul id="user-control-list" class="dropdown-menu" aria-labelledby="user_dropdown">
|
||||
<li>
|
||||
<a href="#" class="reload" title="Reload Forum">
|
||||
Reload Forum
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="restart" title="Restart Forum">
|
||||
Restart Forum
|
||||
|
||||
Reference in New Issue
Block a user