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",
|
||||
"express": "^4.18.2",
|
||||
"ini": "^2.0.0",
|
||||
"kill-process-by-name": "^1.0.5",
|
||||
"node-google-tts-api": "^1.1.1",
|
||||
"querystring": "^0.2.1",
|
||||
"socket.io": "^4.7.1",
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ SetLogLevel(-1)
|
|||
settings = configparser.ConfigParser()
|
||||
app = Flask(__name__)
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
settingsPath = os.path.normpath(sys.argv[1])
|
||||
environment = sys.argv[2]
|
||||
|
||||
settingsPath = os.path.normpath(sys.argv[1])
|
||||
environment = sys.argv[2]
|
||||
q = queue.Queue()
|
||||
|
||||
|
||||
# gobal functions
|
||||
|
||||
# classes
|
||||
|
|
@ -79,7 +79,7 @@ class STT:
|
|||
def __init__(self):
|
||||
settings.read(settingsPath)
|
||||
device_info = sd.query_devices(int(settings["STT"]["MICROPHONE"]), "input")
|
||||
self.samplerate = int(device_info["default_samplerate"])
|
||||
self.samplerate = int(device_info["default_samplerate"])
|
||||
|
||||
if environment == "dev":
|
||||
settings_folder = os.path.dirname(settingsPath)
|
||||
|
|
@ -277,3 +277,4 @@ if __name__ == "__main__":
|
|||
stream_recognition()
|
||||
|
||||
app.run(host="127.0.0.1", port=port)
|
||||
app.terminate()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const spawn = require('child_process').spawn;
|
||||
var kill = require('kill-process-by-name');
|
||||
let python;
|
||||
|
||||
async function getInstalledVoices() {
|
||||
|
|
@ -145,17 +146,21 @@ async function initiateBackend() {
|
|||
|
||||
initiateBackend();
|
||||
|
||||
//TODO: convert to restartServer function
|
||||
ipcRenderer.on('quit-event', async () => {
|
||||
try {
|
||||
const response = await fetch(`http://127.0.0.1:${settings.GENERAL.PORT}/terminate`, { method: 'GET' });
|
||||
if (response.ok) {
|
||||
const responseData = await response.json();
|
||||
console.log('Response:', responseData);
|
||||
kill('loquendoBot_backend');
|
||||
} else {
|
||||
console.error('Failed to send termination signal to Flask server.');
|
||||
kill('loquendoBot_backend');
|
||||
}
|
||||
} catch (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 path = require('path');
|
||||
const http = require('http');
|
||||
const kill = require('kill-process-by-name');
|
||||
|
||||
const ini = require('ini');
|
||||
const fs = require('fs');
|
||||
|
|
@ -109,6 +110,7 @@ ipcMain.on('maximize-window', (event) => {
|
|||
|
||||
ipcMain.on('close-window', (event) => {
|
||||
const browserWindow = BrowserWindow.fromWebContents(event.sender);
|
||||
kill('loquendoBot_backend');
|
||||
browserWindow.close();
|
||||
app.quit();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue