re: #5211, bringing back the RELOAD BUTTON :rage2:

v1.18.x
Julian Lam 8 years ago
parent a3efe42938
commit 0e8bf17ff0

@ -124,22 +124,26 @@
}
function setupRestartLinks() {
$('.restart').off('click').on('click', function () {
bootbox.confirm('Are you sure you wish to restart NodeBB?', function (confirm) {
$('.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.restart();
instance.reload();
});
}
});
});
$('.reload').off('click').on('click', function () {
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) {
require(['admin/modules/instance'], function (instance) {
instance.restart();
});
}
});
});
}
};
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,37 +14,30 @@ 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 + ']]'
});
}
$(window).one('action:reconnected', function () {
app.alert({
alert_id: 'instance_reload',
type: 'success',
title: '<i class="fa fa-check"></i> Success',
message: 'NodeBB has reloaded successfully.',
timeout: 5000
});
if (typeof callback === 'function') {
callback();
}
});
socket.emit('admin.reload');
};
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
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 () {
@ -53,7 +46,7 @@ define('admin/modules/instance', function () {
type: 'success',
title: '<i class="fa fa-check"></i> Success',
message: 'NodeBB has successfully restarted.',
timeout: 5000
timeout: 10000
});
if (typeof callback === 'function') {
@ -61,7 +54,15 @@ define('admin/modules/instance', function () {
}
});
socket.emit('admin.restart');
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();
};
}
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
});
/**
* Reload deprecated as of v1.1.2+, remove in v2.x
*/
SocketAdmin.reload = SocketAdmin.restart;
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

Loading…
Cancel
Save