Skip to content

Commit

Permalink
fix: wait for event.log to finish before killing process
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Feb 10, 2021
1 parent 0185ea1 commit a5fa212
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/socket.io/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,18 @@ SocketAdmin.before = async function (socket, method) {
throw new Error('[[error:no-privileges]]');
};

SocketAdmin.restart = function (socket, data, callback) {
logRestart(socket);
SocketAdmin.restart = async function (socket) {
await logRestart(socket);
meta.restart();
callback();
};

function logRestart(socket) {
events.log({
async function logRestart(socket) {
await events.log({
type: 'restart',
uid: socket.uid,
ip: socket.ip,
});
db.setObject('lastrestart', {
await db.setObject('lastrestart', {
uid: socket.uid,
ip: socket.ip,
timestamp: Date.now(),
Expand All @@ -80,7 +79,7 @@ SocketAdmin.reload = async function (socket) {
ip: socket.ip,
});

logRestart(socket);
await logRestart(socket);
meta.restart();
};

Expand Down

0 comments on commit a5fa212

Please sign in to comment.