1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

JS-2036: sigusr signal

This commit is contained in:
Andrew Simachev 2023-05-31 16:06:44 +02:00
parent 30e27bc68b
commit 97db0a0010
No known key found for this signature in database
GPG key ID: 49A163D0D14E6FD8
5 changed files with 21 additions and 10 deletions

View file

@ -59,12 +59,12 @@ let csp = [
if (is.development && !port) {
console.error('ERROR: Please define SERVER_PORT env var');
Api.exit(mainWindow, false);
Api.exit(mainWindow, '', false);
return;
};
if (app.isPackaged && !app.requestSingleInstanceLock()) {
Api.exit(mainWindow, false);
Api.exit(mainWindow, '' ,false);
return;
};
@ -188,7 +188,7 @@ app.on('before-quit', (e) => {
app.exit(0);
} else {
e.preventDefault();
Api.exit(mainWindow, false);
Api.exit(mainWindow, '', false);
};
});

View file

@ -140,7 +140,7 @@ class Api {
};
};
exit (win, relaunch) {
exit (win, signal, relaunch) {
if (app.isQuiting) {
return;
};
@ -152,7 +152,7 @@ class Api {
Util.log('info', '[Api].exit, relaunch: ' + relaunch);
Util.send(win, 'shutdownStart');
Server.stop().then(() => { this.shutdown(win, relaunch); });
Server.stop(signal).then(() => { this.shutdown(win, relaunch); });
};
};

View file

@ -5,6 +5,7 @@ const userPath = app.getPath('userData');
const logPath = path.join(userPath, 'logs');
const ConfigManager = require('./config.js');
const Server = require('./server.js');
const Util = require('./util.js');
const Separator = { type: 'separator' };
@ -48,7 +49,7 @@ class MenuManager {
Separator,
{ label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: () => { Api.exit(this.win, false); } },
{ label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: () => { Api.exit(this.win, '', false); } },
]
},
{
@ -72,6 +73,13 @@ class MenuManager {
{ label: 'Space debug', click: () => { Util.send(this.win, 'command', 'debugSpace'); } },
{ label: 'Current object debug', click: () => { this.win.show(); Util.send(this.win, 'command', 'debugTree'); } },
{
label: 'Process debug',
click: () => {
Api.exit(this.win, 'SIGUSR1', true);
shell.openPath(path.join(Util.dataPath(), Api.account.id, 'logs'));
}
},
Separator,
@ -338,7 +346,7 @@ class MenuManager {
Separator,
{ label: 'Quit', click: () => { hide(); Api.exit(this.win, false); } },
{ label: 'Quit', click: () => { hide(); Api.exit(this.win, '', false); } },
]));
};

View file

@ -6,6 +6,7 @@ const stdoutWebProxyPrefix = 'gRPC Web proxy started at: ';
const { app, dialog, shell } = require('electron');
const Util = require('./util.js');
const { sign } = require('crypto');
let maxStdErrChunksBuffer = 10;
@ -100,7 +101,9 @@ class Server {
});
};
stop () {
stop (signal) {
signal = String(signal || 'SIGTERM');
return new Promise((resolve, reject) => {
if (this.cp && this.isRunning) {
this.cp.on('exit', () => {
@ -117,7 +120,7 @@ class Server {
};
});
};
getAddress () {
return this.address;
};

View file

@ -85,7 +85,7 @@ class UpdateManager {
Util.send(this.win, 'update-downloaded');
if (!this.autoUpdate) {
Api.exit(this.win, true);
Api.exit(this.win, '', true);
} else {
Util.send(this.win, 'update-confirm');
};