fixed shutdown error.
This commit is contained in:
parent
93e7c8337d
commit
e76ff46e4c
4 changed files with 13 additions and 4 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"ini": "^2.0.0",
|
"ini": "^2.0.0",
|
||||||
|
"kill-process-by-name": "^1.0.5",
|
||||||
"node-google-tts-api": "^1.1.1",
|
"node-google-tts-api": "^1.1.1",
|
||||||
"querystring": "^0.2.1",
|
"querystring": "^0.2.1",
|
||||||
"socket.io": "^4.7.1",
|
"socket.io": "^4.7.1",
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,11 @@ SetLogLevel(-1)
|
||||||
settings = configparser.ConfigParser()
|
settings = configparser.ConfigParser()
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
settingsPath = os.path.normpath(sys.argv[1])
|
settingsPath = os.path.normpath(sys.argv[1])
|
||||||
environment = sys.argv[2]
|
environment = sys.argv[2]
|
||||||
q = queue.Queue()
|
|
||||||
|
|
||||||
|
q = queue.Queue()
|
||||||
|
|
||||||
# gobal functions
|
# gobal functions
|
||||||
|
|
||||||
|
|
@ -277,3 +277,4 @@ if __name__ == "__main__":
|
||||||
stream_recognition()
|
stream_recognition()
|
||||||
|
|
||||||
app.run(host="127.0.0.1", port=port)
|
app.run(host="127.0.0.1", port=port)
|
||||||
|
app.terminate()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
var kill = require('kill-process-by-name');
|
||||||
let python;
|
let python;
|
||||||
|
|
||||||
async function getInstalledVoices() {
|
async function getInstalledVoices() {
|
||||||
|
|
@ -145,17 +146,21 @@ async function initiateBackend() {
|
||||||
|
|
||||||
initiateBackend();
|
initiateBackend();
|
||||||
|
|
||||||
|
//TODO: convert to restartServer function
|
||||||
ipcRenderer.on('quit-event', async () => {
|
ipcRenderer.on('quit-event', async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`http://127.0.0.1:${settings.GENERAL.PORT}/terminate`, { method: 'GET' });
|
const response = await fetch(`http://127.0.0.1:${settings.GENERAL.PORT}/terminate`, { method: 'GET' });
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const responseData = await response.json();
|
const responseData = await response.json();
|
||||||
console.log('Response:', responseData);
|
console.log('Response:', responseData);
|
||||||
|
kill('loquendoBot_backend');
|
||||||
} else {
|
} else {
|
||||||
console.error('Failed to send termination signal to Flask server.');
|
console.error('Failed to send termination signal to Flask server.');
|
||||||
|
kill('loquendoBot_backend');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error sending termination signal:', error);
|
console.error('Error sending termination signal:', error);
|
||||||
|
kill('loquendoBot_backend');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ const { app, BrowserWindow, ipcMain } = require('electron');
|
||||||
const { writeIniFile } = require('write-ini-file');
|
const { writeIniFile } = require('write-ini-file');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const kill = require('kill-process-by-name');
|
||||||
|
|
||||||
const ini = require('ini');
|
const ini = require('ini');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
@ -109,6 +110,7 @@ ipcMain.on('maximize-window', (event) => {
|
||||||
|
|
||||||
ipcMain.on('close-window', (event) => {
|
ipcMain.on('close-window', (event) => {
|
||||||
const browserWindow = BrowserWindow.fromWebContents(event.sender);
|
const browserWindow = BrowserWindow.fromWebContents(event.sender);
|
||||||
|
kill('loquendoBot_backend');
|
||||||
browserWindow.close();
|
browserWindow.close();
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue