fix: wait for event.log to finish before killing process

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 0185ea1b4f
commit a5fa212fc7

@ -53,19 +53,18 @@ SocketAdmin.before = async function (socket, method) {
throw new Error('[[error:no-privileges]]'); throw new Error('[[error:no-privileges]]');
}; };
SocketAdmin.restart = function (socket, data, callback) { SocketAdmin.restart = async function (socket) {
logRestart(socket); await logRestart(socket);
meta.restart(); meta.restart();
callback();
}; };
function logRestart(socket) { async function logRestart(socket) {
events.log({ await events.log({
type: 'restart', type: 'restart',
uid: socket.uid, uid: socket.uid,
ip: socket.ip, ip: socket.ip,
}); });
db.setObject('lastrestart', { await db.setObject('lastrestart', {
uid: socket.uid, uid: socket.uid,
ip: socket.ip, ip: socket.ip,
timestamp: Date.now(), timestamp: Date.now(),
@ -80,7 +79,7 @@ SocketAdmin.reload = async function (socket) {
ip: socket.ip, ip: socket.ip,
}); });
logRestart(socket); await logRestart(socket);
meta.restart(); meta.restart();
}; };

Loading…
Cancel
Save