From 7760a6b2074babb262dddb5dbd074b5042e85b22 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sat, 22 Feb 2014 03:11:13 -0500 Subject: [PATCH] added restart button to ACP (!!) --- public/src/forum/admin/index.js | 4 ++++ public/templates/admin/index.tpl | 3 +++ src/meta.js | 8 ++++++++ src/socket.io/admin.js | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/public/src/forum/admin/index.js b/public/src/forum/admin/index.js index 914676115d..1870884328 100644 --- a/public/src/forum/admin/index.js +++ b/public/src/forum/admin/index.js @@ -31,6 +31,10 @@ define(function() { checkEl.append('

A new version (v' + latestVersion + ') has been released. Consider upgrading your NodeBB.

'); } }); + + $('.restart').on('click', function() { + socket.emit('admin.restart'); + }); }; Admin.updateRoomUsage = function(err, data) { diff --git a/public/templates/admin/index.tpl b/public/templates/admin/index.tpl index a6b8db55be..2d548c459c 100644 --- a/public/templates/admin/index.tpl +++ b/public/templates/admin/index.tpl @@ -22,6 +22,9 @@

Always make sure that your NodeBB is up to date for the latest security patches and bug fixes.

+

+ +

diff --git a/src/meta.js b/src/meta.js index c1eb612744..419f293648 100644 --- a/src/meta.js +++ b/src/meta.js @@ -336,4 +336,12 @@ var fs = require('fs'), db.getFileName(callback); } }; + + Meta.restart = function() { + if (process.send) { + process.send('nodebb:restart'); + } else { + winston.error('[meta.restart] Could not restart, are you sure NodeBB was started with `./nodebb start`?'); + } + }; }(exports)); diff --git a/src/socket.io/admin.js b/src/socket.io/admin.js index 21f3d8bf11..3f674f2d65 100644 --- a/src/socket.io/admin.js +++ b/src/socket.io/admin.js @@ -31,6 +31,10 @@ SocketAdmin.before = function(socket, next) { }); }; +SocketAdmin.restart = function(socket, data, callback) { + meta.restart(); +}; + /* Topics */ SocketAdmin.topics = {};