From e1b5872e26a94bf27631ab3093916b7e334f858d Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 15:05:54 +0100 Subject: [PATCH 01/45] first attempt creating a full bundle --- ..._server_nsis.yml => build_nsis_bundle.yml} | 23 ++++-- ...sis-config.nsi => freedata-nsis-config.nsi | 72 ++++++++----------- gui/electron-builder.json5 | 2 +- 3 files changed, 48 insertions(+), 49 deletions(-) rename .github/workflows/{build_server_nsis.yml => build_nsis_bundle.yml} (68%) rename freedata-server-nsis-config.nsi => freedata-nsis-config.nsi (51%) diff --git a/.github/workflows/build_server_nsis.yml b/.github/workflows/build_nsis_bundle.yml similarity index 68% rename from .github/workflows/build_server_nsis.yml rename to .github/workflows/build_nsis_bundle.yml index 4fe89779..d1c6f588 100644 --- a/.github/workflows/build_server_nsis.yml +++ b/.github/workflows/build_nsis_bundle.yml @@ -14,6 +14,21 @@ jobs: with: python-version: "3.11" + - name: Electron Builder + env: # Setting environment variables for the entire job + GH_TOKEN: ${{ secrets.github_token }} + APPLE_ID: ${{ secrets.APPLE_ID }} + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + working-directory: gui + run: | + npm i + npm run build + + - name: LIST ALL FILES + run: ls -R + - name: Install Python dependencies run: | python -m pip install --upgrade pip @@ -38,7 +53,7 @@ jobs: - name: Create installer uses: joncloud/makensis-action@v4 with: - script-file: "freedata-server-nsis-config.nsi" + script-file: "freedata-nsis-config.nsi" arguments: '/V3' - name: LIST ALL FILES @@ -47,12 +62,12 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: 'FreeData-Server-Installer' - path: ./FreeData-Server-Installer.exe + name: 'FreeDATA-Installer' + path: ./FreeDATA-Installer.exe - name: Upload Installer to Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') with: draft: true - files: ./FreeData-Server-Installer.exe + files: ./FreeDATA-Installer.exe diff --git a/freedata-server-nsis-config.nsi b/freedata-nsis-config.nsi similarity index 51% rename from freedata-server-nsis-config.nsi rename to freedata-nsis-config.nsi index a7ec2948..b862ea7a 100644 --- a/freedata-server-nsis-config.nsi +++ b/freedata-nsis-config.nsi @@ -4,16 +4,14 @@ RequestExecutionLevel admin ; The name and file name of the installer -Name "FreeData Server" -OutFile "FreeData-Server-Installer.exe" +Name "FreeDATA Installer" +OutFile "FreeDATA-Installer.exe" -; Default installation directory -; InstallDir "$PROGRAMFILES\FreeData\freedata-server" - -InstallDir "$LOCALAPPDATA\FreeData\freedata-server" +; Default installation directory for the server +InstallDir "$LOCALAPPDATA\FreeDATA" ; Registry key to store the installation directory -InstallDirRegKey HKCU "Software\FreeData\freedata-server" "Install_Dir" +InstallDirRegKey HKCU "Software\FreeDATA" "Install_Dir" ; Modern UI settings !define MUI_ABORTWARNING @@ -22,19 +20,15 @@ InstallDirRegKey HKCU "Software\FreeData\freedata-server" "Install_Dir" !define MUI_ICON "documentation\icon.ico" !define MUI_UNICON "documentation\icon.ico" ; Icon for the uninstaller - ; Define the welcome page text -!define MUI_WELCOMEPAGE_TEXT "Welcome to the FreeData Server Setup Wizard. This wizard will guide you through the installation process." +!define MUI_WELCOMEPAGE_TEXT "Welcome to the FreeDATA Setup Wizard. This wizard will guide you through the installation process." !define MUI_FINISHPAGE_TEXT "Folder: $INSTDIR" - - -!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the installation folder. Its recommended using the suggested one for avoiding permission problems." - +!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the installation folder. It's recommended to use the suggested one to avoid permission problems." ; Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "LICENSE" -;!insertmacro MUI_PAGE_COMPONENTS +!insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH @@ -50,53 +44,43 @@ InstallDirRegKey HKCU "Software\FreeData\freedata-server" "Install_Dir" ; Installer Sections Section "FreeData Server" SEC01 - ; Set output path to the installation directory - SetOutPath $INSTDIR + SetOutPath $INSTDIR\freedata-server - ; Check if "config.ini" exists and back it up - IfFileExists $INSTDIR\config.ini backupConfig - -doneBackup: ; Add your application files here - File /r "modem\server.dist\*.*" - - ; Restore the original "config.ini" if it was backed up - IfFileExists $INSTDIR\config.ini.bak restoreConfig - - + File /r "modem\server.dist\*" ; Create a shortcut in the user's desktop - CreateShortCut "$DESKTOP\FreeData Server.lnk" "$INSTDIR\freedata-server.exe" + CreateShortCut "$DESKTOP\FreeDATA Server.lnk" "$INSTDIR\freedata-server.exe" ; Create Uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" +SectionEnd -; Backup "config.ini" before overwriting files -backupConfig: - Rename $INSTDIR\config.ini $INSTDIR\config.ini.bak - Goto doneBackup - -; Restore the original "config.ini" -restoreConfig: - Delete $INSTDIR\config.ini - Rename $INSTDIR\config.ini.bak $INSTDIR\config.ini +Section "FreeData GUI" SEC02 + ; Set output path to the GUI installation directory + SetOutPath $INSTDIR\freedata-gui + ; Add GUI files here + File /r "gui\release\windows-unpacked\*" + ; Create a shortcut on the desktop for the GUI + CreateShortCut "$DESKTOP\FreeDATA GUI.lnk" "$INSTDIR\freedata-gui\freedata.exe" SectionEnd ; Uninstaller Section Section "Uninstall" - - ; Delete files and directories + ; Delete files and directories for the server Delete $INSTDIR\freedata-server.exe - RMDir /r $INSTDIR + RMDir /r $INSTDIR\freedata-server - ; Remove the shortcut - Delete "$DESKTOP\FreeData Server.lnk" + ; Delete files and directories for the GUI + Delete $INSTDIR\freedata-gui\*.* + RMDir /r $INSTDIR\freedata-gui + + ; Remove the desktop shortcuts + Delete "$DESKTOP\FreeDATA Server.lnk" + Delete "$DESKTOP\FreeDATA GUI.lnk" ; Additional uninstallation commands here - SectionEnd - - diff --git a/gui/electron-builder.json5 b/gui/electron-builder.json5 index cf11795a..c1b5d6cd 100644 --- a/gui/electron-builder.json5 +++ b/gui/electron-builder.json5 @@ -45,7 +45,7 @@ "icon": "build/icon.png", "target": [ { - "target": "nsis", + "target": "portable", "arch": ["arm64", "x64"] } ], From 100c871cd9d7456be4432d1cf187cc4de6c380c4 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 15:27:39 +0100 Subject: [PATCH 02/45] first attempt creating a full bundle --- .github/workflows/build_nsis_bundle.yml | 6 ------ freedata-nsis-config.nsi | 4 ++-- gui/electron-builder.json5 | 6 ------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_nsis_bundle.yml b/.github/workflows/build_nsis_bundle.yml index d1c6f588..95fcb538 100644 --- a/.github/workflows/build_nsis_bundle.yml +++ b/.github/workflows/build_nsis_bundle.yml @@ -15,12 +15,6 @@ jobs: python-version: "3.11" - name: Electron Builder - env: # Setting environment variables for the entire job - GH_TOKEN: ${{ secrets.github_token }} - APPLE_ID: ${{ secrets.APPLE_ID }} - APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} working-directory: gui run: | npm i diff --git a/freedata-nsis-config.nsi b/freedata-nsis-config.nsi index b862ea7a..160e0bad 100644 --- a/freedata-nsis-config.nsi +++ b/freedata-nsis-config.nsi @@ -57,12 +57,12 @@ Section "FreeData Server" SEC01 WriteUninstaller "$INSTDIR\Uninstall.exe" SectionEnd -Section "FreeData GUI" SEC02 +Section "FreeData x64 GUI" SEC02 ; Set output path to the GUI installation directory SetOutPath $INSTDIR\freedata-gui ; Add GUI files here - File /r "gui\release\windows-unpacked\*" + File /r "gui\release\win-unpacked\*" ; Create a shortcut on the desktop for the GUI CreateShortCut "$DESKTOP\FreeDATA GUI.lnk" "$INSTDIR\freedata-gui\freedata.exe" diff --git a/gui/electron-builder.json5 b/gui/electron-builder.json5 index c1b5d6cd..a9b83fec 100644 --- a/gui/electron-builder.json5 +++ b/gui/electron-builder.json5 @@ -51,12 +51,6 @@ ], "artifactName": "${productName}-GUI-Windows-${version}.${ext}" }, - "nsis": { - "oneClick": false, - "perMachine": false, - "allowToChangeInstallationDirectory": true, - "deleteAppDataOnUninstall": true - }, "linux": { "category": "Development", "target": [ From 84504f734f8c30430d1c15c3b374daf85a7b755b Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 16:36:56 +0100 Subject: [PATCH 03/45] removed updater, auto start server --- gui/electron/main/index.ts | 149 ++++--------------- gui/electron/preload/index.ts | 81 +--------- gui/src/components/settings.vue | 31 +--- gui/src/components/settings_updater.vue | 16 -- gui/src/components/settings_updater_core.vue | 102 ------------- 5 files changed, 34 insertions(+), 345 deletions(-) delete mode 100644 gui/src/components/settings_updater.vue delete mode 100644 gui/src/components/settings_updater_core.vue diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index cf4e9636..11f02846 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -1,7 +1,6 @@ import { app, BrowserWindow, shell, ipcMain } from "electron"; import { release, platform } from "node:os"; import { join } from "node:path"; -import { autoUpdater } from "electron-updater"; import { existsSync } from "fs"; import { spawn } from "child_process"; @@ -40,7 +39,7 @@ if (!app.requestSingleInstanceLock()) { // process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true' // set daemon process var -var daemonProcess = null; +var serverProcess = null; let win: BrowserWindow | null = null; // Here, you can also use other preload const preload = join(__dirname, "../preload/index.js"); @@ -87,12 +86,7 @@ async function createWindow() { // win.webContents.on('will-navigate', (event, url) => { }) #344 win.once("ready-to-show", () => { - //autoUpdater.logger = log.scope("updater"); - //autoUpdater.channel = config.update_channel; - autoUpdater.autoInstallOnAppQuit = false; - autoUpdater.autoDownload = true; - autoUpdater.checkForUpdatesAndNotify(); - //autoUpdater.quitAndInstall(); + // }); } @@ -102,64 +96,51 @@ app.whenReady().then(() => { console.log(platform()); //Generate daemon binary path - var daemonPath = ""; + var serverPath = ""; switch (platform().toLowerCase()) { - case "darwin": - daemonPath = join(process.resourcesPath, "modem", "freedata-server"); - case "linux": - daemonPath = join(process.resourcesPath, "modem", "freedata-server"); - break; + //case "darwin": + // serverPath = join(process.resourcesPath, "modem", "freedata-server"); + //case "linux": + // serverPath = join(process.resourcesPath, "modem", "freedata-server"); + // break; case "win32": - daemonPath = join(process.resourcesPath, "modem", "freedata-server.exe"); - break; case "win64": - daemonPath = join(process.resourcesPath, "modem", "freedata-server.exe"); - break; + serverPath = join(process.env.LOCALAPPDATA, "FreeDATA", "freedata-server", "freedata-server.exe"); + break; default: console.log("Unhandled OS Platform: ", platform()); break; } //Start daemon binary if it exists - if (existsSync(daemonPath)) { + if (existsSync(serverPath)) { console.log("Starting freedata-server binary"); - console.log("daemonPath:", daemonPath); - console.log("CWD:", join(daemonPath, "..")); - /* - var daemonProcess = spawn("freedata-server", [], { - cwd: join(process.env.DIST, "modem"), - shell: true - }); -*/ - /* -daemonProcess = spawn(daemonPath, [], { - shell: true - }); - console.log(daemonProcess) -*/ - daemonProcess = spawn(daemonPath, [], {}); + console.log("serverPath:", serverPath); + console.log("CWD:", join(serverPath, "..")); + + serverProcess = spawn(serverPath, [], { shell: true }); // return process messages - daemonProcess.on("error", (err) => { - //daemonProcessLog.error(`error when starting daemon: ${err}`); + serverProcess.on("error", (err) => { + //serverProcessLog.error(`error when starting daemon: ${err}`); console.log(err); }); - daemonProcess.on("message", () => { - // daemonProcessLog.info(`${data}`); + serverProcess.on("message", () => { + // serverProcessLog.info(`${data}`); }); - daemonProcess.stdout.on("data", () => { - // daemonProcessLog.info(`${data}`); + serverProcess.stdout.on("data", () => { + // serverProcessLog.info(`${data}`); }); - daemonProcess.stderr.on("data", (data) => { - // daemonProcessLog.info(`${data}`); + serverProcess.stderr.on("data", (data) => { + // serverProcessLog.info(`${data}`); console.log(data); }); - daemonProcess.on("close", (code) => { - // daemonProcessLog.warn(`daemonProcess exited with code ${code}`); + serverProcess.on("close", (code) => { + // serverProcessLog.warn(`serverProcess exited with code ${code}`); }); } else { - daemonProcess = null; - daemonPath = null; + serverProcess = null; + serverPath = null; console.log("Daemon binary doesn't exist--normal for dev environments."); } @@ -205,101 +186,31 @@ ipcMain.handle("open-win", (_, arg) => { } }); -//restart and install udpate -ipcMain.on("request-restart-and-install-update", (event, data) => { - close_sub_processes(); - autoUpdater.quitAndInstall(); -}); -// LISTENER FOR UPDATER EVENTS -autoUpdater.on("update-available", (info) => { - process.env.FDUpdateAvail = "1"; - console.log("update available"); - - let arg = { - status: "update-available", - info: info, - }; - win.webContents.send("action-updater", arg); -}); - -autoUpdater.on("update-not-available", (info) => { - console.log("update not available"); - let arg = { - status: "update-not-available", - info: info, - }; - win.webContents.send("action-updater", arg); -}); - -autoUpdater.on("update-downloaded", (info) => { - process.env.FDUpdateAvail = "1"; - console.log("update downloaded"); - let arg = { - status: "update-downloaded", - info: info, - }; - win.webContents.send("action-updater", arg); - // we need to call this at this point. - // if an update is available and we are force closing the app - // the entire screen crashes... - //console.log('quit application and install update'); - //autoUpdater.quitAndInstall(); -}); - -autoUpdater.on("checking-for-update", () => { - console.log("checking for update"); - let arg = { - status: "checking-for-update", - version: app.getVersion(), - }; - win.webContents.send("action-updater", arg); -}); - -autoUpdater.on("download-progress", (progress) => { - let arg = { - status: "download-progress", - progress: progress, - }; - win.webContents.send("action-updater", arg); -}); - -autoUpdater.on("error", (error) => { - console.log("update error"); - let arg = { - status: "error", - progress: error, - }; - win.webContents.send("action-updater", arg); - console.log("AUTO UPDATER : " + error); -}); function close_sub_processes() { console.log("closing sub processes"); // closing the modem binary if not closed when closing application and also our daemon which has been started by the gui try { - if (daemonProcess != null) { - daemonProcess.kill(); + if (serverProcess != null) { + serverProcess.kill(); } } catch (e) { console.log(e); } - console.log("closing modem and daemon"); + console.log("closing freedata server process"); try { if (platform() == "win32") { - spawn("Taskkill", ["/IM", "freedata-modem.exe", "/F"]); spawn("Taskkill", ["/IM", "freedata-server.exe", "/F"]); } if (platform() == "linux") { - spawn("pkill", ["-9", "freedata-modem"]); spawn("pkill", ["-9", "freedata-server"]); } if (platform() == "darwin") { - spawn("pkill", ["-9", "freedata-modem"]); spawn("pkill", ["-9", "freedata-server"]); } } catch (e) { diff --git a/gui/electron/preload/index.ts b/gui/electron/preload/index.ts index 69e18a1e..03708df3 100644 --- a/gui/electron/preload/index.ts +++ b/gui/electron/preload/index.ts @@ -111,83 +111,4 @@ window.onmessage = (ev) => { ev.data.payload === "removeLoading" && removeLoading(); }; -setTimeout(removeLoading, 4999); - -// IPC ACTION FOR AUTO UPDATER -ipcRenderer.on("action-updater", (event, arg) => { - if (arg.status == "download-progress") { - var progressinfo = - "(" + - Math.round(arg.progress.transferred / 1024) + - "kB /" + - Math.round(arg.progress.total / 1024) + - "kB)" + - " @ " + - Math.round(arg.progress.bytesPerSecond / 1024) + - "kByte/s"; - document.getElementById("UpdateProgressInfo").innerHTML = progressinfo; - - document - .getElementById("UpdateProgressBar") - .setAttribute("aria-valuenow", arg.progress.percent); - document - .getElementById("UpdateProgressBar") - .setAttribute("style", "width:" + arg.progress.percent + "%;"); - } - - if (arg.status == "checking-for-update") { - //document.title = document.title + ' - v' + arg.version; - //updateTitle( - // config.myCall, - // config.tnc_host, - // config.tnc_port, - // " -v " + arg.version, - //); - document.getElementById("updater_status").innerHTML = - ''; - - document.getElementById("updater_status").className = - "btn btn-secondary btn-sm"; - document.getElementById("update_and_install").style.display = "none"; - } - if (arg.status == "update-downloaded") { - document.getElementById("update_and_install").removeAttribute("style"); - document.getElementById("updater_status").innerHTML = - ''; - document.getElementById("updater_status").className = - "btn btn-success btn-sm"; - - // HERE WE NEED TO RUN THIS SOMEHOW... - //mainLog.info('quit application and install update'); - //autoUpdater.quitAndInstall(); - } - if (arg.status == "update-not-available") { - document.getElementById("updater_last_version").innerHTML = - arg.info.releaseName; - document.getElementById("updater_last_update").innerHTML = - arg.info.releaseDate; - document.getElementById("updater_release_notes").innerHTML = - arg.info.releaseNotes; - - document.getElementById("updater_status").innerHTML = - ''; - document.getElementById("updater_status").className = - "btn btn-success btn-sm"; - document.getElementById("update_and_install").style.display = "none"; - } - if (arg.status == "update-available") { - document.getElementById("updater_status").innerHTML = - ''; - document.getElementById("updater_status").className = - "btn btn-warning btn-sm"; - document.getElementById("update_and_install").style.display = "none"; - } - - if (arg.status == "error") { - document.getElementById("updater_status").innerHTML = - ''; - document.getElementById("updater_status").className = - "btn btn-danger btn-sm"; - document.getElementById("update_and_install").style.display = "none"; - } -}); +setTimeout(removeLoading, 3999); diff --git a/gui/src/components/settings.vue b/gui/src/components/settings.vue index 718e660e..f230bf97 100644 --- a/gui/src/components/settings.vue +++ b/gui/src/components/settings.vue @@ -1,5 +1,4 @@ - - diff --git a/gui/src/components/settings_updater_core.vue b/gui/src/components/settings_updater_core.vue deleted file mode 100644 index b83cd823..00000000 --- a/gui/src/components/settings_updater_core.vue +++ /dev/null @@ -1,102 +0,0 @@ - - - From 2ea6a4fe139ee6319bda55a643f50d1a8ab72732 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 16:46:56 +0100 Subject: [PATCH 04/45] removed updater, auto start server --- gui/electron/main/index.ts | 1 - gui/src/components/main_startup_check.vue | 19 ++----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 11f02846..e76057a9 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -19,7 +19,6 @@ process.env.DIST = join(process.env.DIST_ELECTRON, "../dist"); process.env.VITE_PUBLIC = process.env.VITE_DEV_SERVER_URL ? join(process.env.DIST_ELECTRON, "../public") : process.env.DIST; -process.env.FDUpdateAvail = "0"; // Disable GPU Acceleration for Windows 7 if (release().startsWith("6.1")) app.disableHardwareAcceleration(); diff --git a/gui/src/components/main_startup_check.vue b/gui/src/components/main_startup_check.vue index e9d3b238..61d3d853 100644 --- a/gui/src/components/main_startup_check.vue +++ b/gui/src/components/main_startup_check.vue @@ -2,7 +2,6 @@ import { Modal } from "bootstrap"; import { onMounted } from "vue"; -import settings_updater_core from "./settings_updater_core.vue"; import { setActivePinia } from "pinia"; import pinia from "../store/index"; @@ -25,7 +24,6 @@ import { audioInputOptions, audioOutputOptions } from "../js/deviceFormHelper"; import { serialDeviceOptions } from "../js/deviceFormHelper"; const version = import.meta.env.PACKAGE_VERSION; -var updateAvailable = process.env.FDUpdateAvail; // start modemCheck modal once on startup onMounted(() => { @@ -392,18 +390,7 @@ function testHamlib() { data-bs-toggle="collapse" > Version - - {{ - updateAvailable === "1" - ? "Update available ! ! ! !" - : "Current" - }} +
Modem version | {{ state.modem_version }} -
- -
+
From 2f21dc6abc2e28ff5e1904fb816642c60608dd67 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 17:45:40 +0100 Subject: [PATCH 05/45] adjusted server lookup path --- gui/electron/main/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index e76057a9..20381481 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -96,6 +96,7 @@ app.whenReady().then(() => { console.log(platform()); //Generate daemon binary path var serverPath = ""; + switch (platform().toLowerCase()) { //case "darwin": // serverPath = join(process.resourcesPath, "modem", "freedata-server"); @@ -104,7 +105,7 @@ app.whenReady().then(() => { // break; case "win32": case "win64": - serverPath = join(process.env.LOCALAPPDATA, "FreeDATA", "freedata-server", "freedata-server.exe"); + serverPath = join(__dirname, "..", "freedata-server", "freedata-server.exe"); break; default: console.log("Unhandled OS Platform: ", platform()); From 6c9439ac7072b03dcf9d4846f8e309e5f06ed40b Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 17:46:34 +0100 Subject: [PATCH 06/45] adjusted server lookup path --- gui/electron/main/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 20381481..90b25135 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -1,6 +1,6 @@ import { app, BrowserWindow, shell, ipcMain } from "electron"; import { release, platform } from "node:os"; -import { join } from "node:path"; +import { join, dirname } from "node:path"; import { existsSync } from "fs"; import { spawn } from "child_process"; From 515f895ed39c9c460a7a4d8a2fb6d499c0932afa Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 19:33:12 +0100 Subject: [PATCH 07/45] more error handling --- gui/electron/main/index.ts | 39 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 90b25135..8df691b2 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -111,37 +111,28 @@ app.whenReady().then(() => { console.log("Unhandled OS Platform: ", platform()); break; } - + console.log("serverPath:", serverPath); //Start daemon binary if it exists if (existsSync(serverPath)) { - console.log("Starting freedata-server binary"); - console.log("serverPath:", serverPath); - console.log("CWD:", join(serverPath, "..")); + console.log(`Starting server with path: ${serverPath}`); +serverProcess = spawn(serverPath, [], { shell: true }); + + serverProcess.on('error', (err) => { + console.error('Failed to start server process:', err); +}); +serverProcess.stdout.on('data', (data) => { + console.log(`stdout: ${data}`); +}); + +serverProcess.stderr.on('data', (data) => { + console.error(`stderr: ${data}`); +}); - serverProcess = spawn(serverPath, [], { shell: true }); - // return process messages - serverProcess.on("error", (err) => { - //serverProcessLog.error(`error when starting daemon: ${err}`); - console.log(err); - }); - serverProcess.on("message", () => { - // serverProcessLog.info(`${data}`); - }); - serverProcess.stdout.on("data", () => { - // serverProcessLog.info(`${data}`); - }); - serverProcess.stderr.on("data", (data) => { - // serverProcessLog.info(`${data}`); - console.log(data); - }); - serverProcess.on("close", (code) => { - // serverProcessLog.warn(`serverProcess exited with code ${code}`); - }); } else { serverProcess = null; serverPath = null; - console.log("Daemon binary doesn't exist--normal for dev environments."); + console.log("Server binary doesn't exist in setup folder"); } //) From b2657bcbbdf48e6d9d03b1a16e079d5e7bee2842 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Thu, 29 Feb 2024 20:34:27 +0100 Subject: [PATCH 08/45] adjusted codec2 file search path --- modem/codec2.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modem/codec2.py b/modem/codec2.py index 9cc7a817..380ec372 100644 --- a/modem/codec2.py +++ b/modem/codec2.py @@ -74,23 +74,21 @@ def freedv_get_mode_name_by_value(mode: int) -> str: return FREEDV_MODE(mode).name -# Check if we are running in a pyinstaller environment -#if hasattr(sys, "_MEIPASS"): -# sys.path.append(getattr(sys, "_MEIPASS")) -#else: -sys.path.append(os.path.abspath(".")) +# Get the directory of the current script file +script_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(script_dir) -#log.info("[C2 ] Searching for libcodec2...") +# Use script_dir to construct the paths for file search if sys.platform == "linux": - files = glob.glob(r"**/*libcodec2*", recursive=True) - files.append("libcodec2.so") + files = glob.glob(os.path.join(script_dir, "**/*libcodec2*"), recursive=True) + files.append(os.path.join(script_dir, "libcodec2.so")) elif sys.platform == "darwin": if hasattr(sys, "_MEIPASS"): - files = glob.glob(getattr(sys, "_MEIPASS") + '/**/*libcodec2*', recursive=True) + files = glob.glob(os.path.join(getattr(sys, "_MEIPASS"), '**/*libcodec2*'), recursive=True) else: - files = glob.glob(r"**/*libcodec2*.dylib", recursive=True) + files = glob.glob(os.path.join(script_dir, "**/*libcodec2*.dylib"), recursive=True) elif sys.platform in ["win32", "win64"]: - files = glob.glob(r"**\*libcodec2*.dll", recursive=True) + files = glob.glob(os.path.join(script_dir, "**\\*libcodec2*.dll"), recursive=True) else: files = [] From 2ee47766933b8924a39616efd00cc695139dd149 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Fri, 1 Mar 2024 09:44:57 +0100 Subject: [PATCH 09/45] adjusted lookup path --- gui/electron/main/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 8df691b2..ef3a5d41 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -105,12 +105,13 @@ app.whenReady().then(() => { // break; case "win32": case "win64": - serverPath = join(__dirname, "..", "freedata-server", "freedata-server.exe"); + serverPath = join(process.env.PWD, "..", "freedata-server", "freedata-server.exe"); break; default: console.log("Unhandled OS Platform: ", platform()); break; } + console.log(process.env.PWD) console.log("serverPath:", serverPath); //Start daemon binary if it exists if (existsSync(serverPath)) { From 14cbd46a88528547ccbe7cfb5cad6d4d0d5e7945 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Fri, 1 Mar 2024 10:39:10 +0100 Subject: [PATCH 10/45] adjusted lookup path --- gui/electron/main/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index ef3a5d41..34e66d79 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -104,16 +104,19 @@ app.whenReady().then(() => { // serverPath = join(process.resourcesPath, "modem", "freedata-server"); // break; case "win32": + serverPath = join(process.env.PWD, "..", "freedata-server", "freedata-server.exe"); + case "win64": serverPath = join(process.env.PWD, "..", "freedata-server", "freedata-server.exe"); + break; default: console.log("Unhandled OS Platform: ", platform()); break; } - console.log(process.env.PWD) + console.log(process.env) console.log("serverPath:", serverPath); - //Start daemon binary if it exists + //Start server binary if it exists if (existsSync(serverPath)) { console.log(`Starting server with path: ${serverPath}`); serverProcess = spawn(serverPath, [], { shell: true }); From e221637394626936ca98ddf8aca698e2ba8ccb40 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Fri, 1 Mar 2024 12:10:49 +0100 Subject: [PATCH 11/45] adjusted lookup path and updated gh action --- .github/workflows/build_nsis_bundle.yml | 2 +- gui/electron/main/index.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_nsis_bundle.yml b/.github/workflows/build_nsis_bundle.yml index 95fcb538..8b6c2a2c 100644 --- a/.github/workflows/build_nsis_bundle.yml +++ b/.github/workflows/build_nsis_bundle.yml @@ -45,7 +45,7 @@ jobs: run: ls -R - name: Create installer - uses: joncloud/makensis-action@v4 + uses: joncloud/makensis-action@v4.1 with: script-file: "freedata-nsis-config.nsi" arguments: '/V3' diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 34e66d79..6be9bc8c 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -96,6 +96,10 @@ app.whenReady().then(() => { console.log(platform()); //Generate daemon binary path var serverPath = ""; + console.log(process.env) + + // Attempt to use PWD; if undefined, use INIT_CWD and adjust accordingly + var basePath = path.join(process.env.PWD, '..') || path.join(process.env.INIT_CWD, '..'); switch (platform().toLowerCase()) { //case "darwin": @@ -104,17 +108,19 @@ app.whenReady().then(() => { // serverPath = join(process.resourcesPath, "modem", "freedata-server"); // break; case "win32": - serverPath = join(process.env.PWD, "..", "freedata-server", "freedata-server.exe"); + + + serverPath = join(basePath, "freedata-server", "freedata-server.exe"); case "win64": - serverPath = join(process.env.PWD, "..", "freedata-server", "freedata-server.exe"); + serverPath = join(basePath, "freedata-server", "freedata-server.exe"); break; default: console.log("Unhandled OS Platform: ", platform()); break; } - console.log(process.env) + console.log("serverPath:", serverPath); //Start server binary if it exists if (existsSync(serverPath)) { From 470503eb5c4ecf88e55a30ae00d5f502c6af301f Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:14:18 +0100 Subject: [PATCH 12/45] adjusted server lookup path --- gui/electron/main/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 6be9bc8c..7ec1be32 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -1,6 +1,6 @@ import { app, BrowserWindow, shell, ipcMain } from "electron"; -import { release, platform } from "node:os"; -import { join, dirname } from "node:path"; +import { release, platform } from "os"; +import { join, dirname } from "path"; import { existsSync } from "fs"; import { spawn } from "child_process"; @@ -98,8 +98,10 @@ app.whenReady().then(() => { var serverPath = ""; console.log(process.env) - // Attempt to use PWD; if undefined, use INIT_CWD and adjust accordingly - var basePath = path.join(process.env.PWD, '..') || path.join(process.env.INIT_CWD, '..'); + // Attempt to find Installation Folder + console.log(app.getAppPath()) + console.log(join(app.getAppPath(), '..', '..')) + var basePath = join(app.getAppPath(), '..', '..') || join(process.env.PWD, '..') || join(process.env.INIT_CWD, '..') || join(process.env.DIST, '..', '..', '..'); switch (platform().toLowerCase()) { //case "darwin": @@ -108,8 +110,6 @@ app.whenReady().then(() => { // serverPath = join(process.resourcesPath, "modem", "freedata-server"); // break; case "win32": - - serverPath = join(basePath, "freedata-server", "freedata-server.exe"); case "win64": From 8081a44e92bff7a6ea55d23f2be1bcb4fb045cf1 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:37:39 +0100 Subject: [PATCH 13/45] adjusted server lookup path --- gui/electron/main/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 7ec1be32..e0517bc1 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -148,6 +148,7 @@ serverProcess.stderr.on('data', (data) => { //) }); +app.on("window-all-closed", () => { app.on("window-all-closed", () => { win = null; if (process.platform !== "darwin") app.quit(); From 1b927ad1837b18e19834185253ca0f556c98f94c Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Fri, 1 Mar 2024 17:04:15 +0100 Subject: [PATCH 14/45] adjusted lookup path and updated gh action --- gui/electron/main/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index e0517bc1..7ec1be32 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -148,7 +148,6 @@ serverProcess.stderr.on('data', (data) => { //) }); -app.on("window-all-closed", () => { app.on("window-all-closed", () => { win = null; if (process.platform !== "darwin") app.quit(); From 297be826ddcb6807fcd796133dac179cd30e69a5 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Fri, 1 Mar 2024 17:55:42 +0100 Subject: [PATCH 15/45] this one should work... --- gui/electron/main/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 7ec1be32..af91e38e 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -101,7 +101,9 @@ app.whenReady().then(() => { // Attempt to find Installation Folder console.log(app.getAppPath()) console.log(join(app.getAppPath(), '..', '..')) - var basePath = join(app.getAppPath(), '..', '..') || join(process.env.PWD, '..') || join(process.env.INIT_CWD, '..') || join(process.env.DIST, '..', '..', '..'); + console.log(join(app.getAppPath(), '..', '..', '..')) + + var basePath = join(app.getAppPath(), '..', '..', '..') || join(process.env.PWD, '..') || join(process.env.INIT_CWD, '..') || join(process.env.DIST, '..', '..', '..'); switch (platform().toLowerCase()) { //case "darwin": From 7ff95571c364ab5a51abf31477fc0ba32abeeef7 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Fri, 1 Mar 2024 21:29:11 +0100 Subject: [PATCH 16/45] adjusted database and config paths --- modem/codec2.py | 1 - modem/message_system_db_attachments.py | 10 +++++++--- modem/message_system_db_beacon.py | 14 ++++++++------ modem/message_system_db_manager.py | 9 +++++++-- modem/message_system_db_messages.py | 12 +++++++++--- modem/server.py | 3 ++- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/modem/codec2.py b/modem/codec2.py index 380ec372..df2c12c0 100644 --- a/modem/codec2.py +++ b/modem/codec2.py @@ -77,7 +77,6 @@ def freedv_get_mode_name_by_value(mode: int) -> str: # Get the directory of the current script file script_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(script_dir) - # Use script_dir to construct the paths for file search if sys.platform == "linux": files = glob.glob(os.path.join(script_dir, "**/*libcodec2*"), recursive=True) diff --git a/modem/message_system_db_attachments.py b/modem/message_system_db_attachments.py index fde67fa6..6e2612c3 100644 --- a/modem/message_system_db_attachments.py +++ b/modem/message_system_db_attachments.py @@ -2,12 +2,16 @@ from message_system_db_manager import DatabaseManager from message_system_db_model import MessageAttachment, Attachment, P2PMessage import json import hashlib - +import os class DatabaseManagerAttachments(DatabaseManager): - def __init__(self, uri='sqlite:///freedata-messages.db'): - super().__init__(uri) + def __init__(self, db_file=None): + if not db_file: + script_dir = os.path.dirname(os.path.abspath(__file__)) + db_path = os.path.join(script_dir, 'freedata-messages.db') + db_file = 'sqlite:///' + db_path + super().__init__(db_file) def add_attachment(self, session, message, attachment_data): diff --git a/modem/message_system_db_beacon.py b/modem/message_system_db_beacon.py index df69458b..6dd7fcdd 100644 --- a/modem/message_system_db_beacon.py +++ b/modem/message_system_db_beacon.py @@ -4,14 +4,16 @@ from sqlalchemy.orm import scoped_session, sessionmaker from threading import local from message_system_db_model import Base, Beacon, Station, Status, Attachment, P2PMessage from datetime import timezone, timedelta, datetime -import json -import structlog -import helpers - +import os class DatabaseManagerBeacon(DatabaseManager): - def __init__(self, uri): - super().__init__(uri) + def __init__(self, db_file=None): + if not db_file: + script_dir = os.path.dirname(os.path.abspath(__file__)) + db_path = os.path.join(script_dir, 'freedata-messages.db') + db_file = 'sqlite:///' + db_path + + super().__init__(db_file) def add_beacon(self, timestamp, callsign, snr, gridsquare): session = None diff --git a/modem/message_system_db_manager.py b/modem/message_system_db_manager.py index c0d5d1c9..ce76b08a 100644 --- a/modem/message_system_db_manager.py +++ b/modem/message_system_db_manager.py @@ -7,12 +7,17 @@ from threading import local from message_system_db_model import Base, Station, Status import structlog import helpers +import os class DatabaseManager: - def __init__(self, event_manger, uri='sqlite:///freedata-messages.db'): + def __init__(self, event_manger, db_file=None): self.event_manager = event_manger + if not db_file: + script_dir = os.path.dirname(os.path.abspath(__file__)) + db_path = os.path.join(script_dir, 'freedata-messages.db') + db_file = 'sqlite:///' + db_path - self.engine = create_engine(uri, echo=False) + self.engine = create_engine(db_file, echo=False) self.thread_local = local() self.session_factory = sessionmaker(bind=self.engine) Base.metadata.create_all(self.engine) diff --git a/modem/message_system_db_messages.py b/modem/message_system_db_messages.py index 4a1eb312..8f061045 100644 --- a/modem/message_system_db_messages.py +++ b/modem/message_system_db_messages.py @@ -4,12 +4,18 @@ from message_system_db_model import Status, P2PMessage from sqlalchemy.exc import IntegrityError from datetime import datetime import json +import os class DatabaseManagerMessages(DatabaseManager): - def __init__(self, uri='sqlite:///freedata-messages.db'): - super().__init__(uri) - self.attachments_manager = DatabaseManagerAttachments(uri) + def __init__(self, db_file=None): + if not db_file: + script_dir = os.path.dirname(os.path.abspath(__file__)) + db_path = os.path.join(script_dir, 'freedata-messages.db') + db_file = 'sqlite:///' + db_path + + super().__init__(db_file) + self.attachments_manager = DatabaseManagerAttachments(db_file) def add_message(self, message_data, statistics, direction='receive', status=None, is_read=True): session = self.get_thread_scoped_session() diff --git a/modem/server.py b/modem/server.py index 87bd73e8..b1b29120 100644 --- a/modem/server.py +++ b/modem/server.py @@ -36,7 +36,8 @@ def set_config(): if 'FREEDATA_CONFIG' in os.environ: config_file = os.environ['FREEDATA_CONFIG'] else: - config_file = 'config.ini' + script_dir = os.path.dirname(os.path.abspath(__file__)) + config_file = os.path.join(script_dir, 'config.ini') if os.path.exists(config_file): print(f"Using config from {config_file}") From d4275642d735f72509b485320ac12a80218cb4f4 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sat, 2 Mar 2024 10:33:44 +0100 Subject: [PATCH 17/45] adjusted server startup and stopping --- gui/electron/main/index.ts | 76 +++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index af91e38e..4d6f5206 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -107,33 +107,31 @@ app.whenReady().then(() => { switch (platform().toLowerCase()) { //case "darwin": - // serverPath = join(process.resourcesPath, "modem", "freedata-server"); + //serverPath = join(basePath, "freedata-server", "freedata-server.exe"); + //serverProcess = spawn(serverPath, [], { detached: true }); + //serverProcess.unref(); // Allow the server process to continue running independently of the parent process + // break; //case "linux": - // serverPath = join(process.resourcesPath, "modem", "freedata-server"); - // break; + //serverPath = join(basePath, "freedata-server", "freedata-server.exe"); + //serverProcess = spawn(serverPath, [], { detached: true }); + //serverProcess.unref(); // Allow the server process to continue running independently of the parent process + // break; case "win32": + console.log(`Starting server with path: ${serverPath}`); serverPath = join(basePath, "freedata-server", "freedata-server.exe"); + serverProcess = spawn('cmd.exe', ['/c', 'start', 'cmd.exe', '/k', serverPath], { shell: true }); + break; - case "win64": - serverPath = join(basePath, "freedata-server", "freedata-server.exe"); - - break; default: - console.log("Unhandled OS Platform: ", platform()); - break; + console.log("Unhandled OS Platform: ", platform()); + break; } - console.log("serverPath:", serverPath); - //Start server binary if it exists - if (existsSync(serverPath)) { - console.log(`Starting server with path: ${serverPath}`); -serverProcess = spawn(serverPath, [], { shell: true }); - serverProcess.on('error', (err) => { console.error('Failed to start server process:', err); }); serverProcess.stdout.on('data', (data) => { - console.log(`stdout: ${data}`); + //console.log(`stdout: ${data}`); }); serverProcess.stderr.on('data', (data) => { @@ -150,6 +148,11 @@ serverProcess.stderr.on('data', (data) => { //) }); +app.on('before-quit', () => { + close_sub_processes(); +}); + + app.on("window-all-closed", () => { win = null; if (process.platform !== "darwin") app.quit(); @@ -189,34 +192,21 @@ ipcMain.handle("open-win", (_, arg) => { } }); - - function close_sub_processes() { - console.log("closing sub processes"); + console.log("Closing sub processes..."); - // closing the modem binary if not closed when closing application and also our daemon which has been started by the gui - try { if (serverProcess != null) { - serverProcess.kill(); + try { + console.log(`Killing server process with PID: ${serverProcess.pid}`); + // For Windows, use taskkill to ensure all child processes are also terminated + if (isWindows) { + spawn("taskkill", ["/pid", serverProcess.pid.toString(), "/f", "/t"]); + } else { + // On macOS and Linux, sending SIGTERM should suffice + process.kill(serverProcess.pid); + } + } catch (error) { + console.error(`Error killing server process: ${error}`); + } } - } catch (e) { - console.log(e); - } - - console.log("closing freedata server process"); - try { - if (platform() == "win32") { - spawn("Taskkill", ["/IM", "freedata-server.exe", "/F"]); - } - - if (platform() == "linux") { - spawn("pkill", ["-9", "freedata-server"]); - } - - if (platform() == "darwin") { - spawn("pkill", ["-9", "freedata-server"]); - } - } catch (e) { - console.log(e); - } -} +} \ No newline at end of file From bab8aad126475afa10246464cabce720362681fd Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sat, 2 Mar 2024 10:41:07 +0100 Subject: [PATCH 18/45] bug fix and added install-deps command --- gui/electron/main/index.ts | 10 ++++------ gui/package.json | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 4d6f5206..9a9cf2f2 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -124,11 +124,15 @@ app.whenReady().then(() => { default: console.log("Unhandled OS Platform: ", platform()); + serverProcess = null; + serverPath = null; break; } serverProcess.on('error', (err) => { console.error('Failed to start server process:', err); + serverProcess = null; + serverPath = null; }); serverProcess.stdout.on('data', (data) => { //console.log(`stdout: ${data}`); @@ -139,12 +143,6 @@ serverProcess.stderr.on('data', (data) => { }); - } else { - serverProcess = null; - serverPath = null; - console.log("Server binary doesn't exist in setup folder"); - } - //) }); diff --git a/gui/package.json b/gui/package.json index 0a4216be..b23c4de7 100644 --- a/gui/package.json +++ b/gui/package.json @@ -13,7 +13,8 @@ "release": "vue-tsc --noEmit && vite build && electron-builder -p onTag", "preview": "vite preview", "lint": "eslint --ext .js,.vue src", - "lint-fix": "eslint --ext .js,.vue --fix src" + "lint-fix": "eslint --ext .js,.vue --fix src", + "install-deps": "npm install && npm update" }, "repository": { "type": "git", From 34dcdd5d8a88d4226a0315a29017320ef173e05e Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sat, 2 Mar 2024 11:38:09 +0100 Subject: [PATCH 19/45] fixed copy and paste error --- gui/electron/main/index.ts | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/gui/electron/main/index.ts b/gui/electron/main/index.ts index 9a9cf2f2..c3eef6cc 100644 --- a/gui/electron/main/index.ts +++ b/gui/electron/main/index.ts @@ -73,9 +73,9 @@ async function createWindow() { } // Test actively push message to the Electron-Renderer - win.webContents.on("did-finish-load", () => { - win?.webContents.send("main-process-message", new Date().toLocaleString()); - }); + //win.webContents.on("did-finish-load", () => { + // win?.webContents.send("main-process-message", new Date().toLocaleString()); + //}); // Make all links open with the browser, not with the application win.webContents.setWindowOpenHandler(({ url }) => { @@ -196,13 +196,26 @@ function close_sub_processes() { if (serverProcess != null) { try { console.log(`Killing server process with PID: ${serverProcess.pid}`); - // For Windows, use taskkill to ensure all child processes are also terminated - if (isWindows) { - spawn("taskkill", ["/pid", serverProcess.pid.toString(), "/f", "/t"]); - } else { - // On macOS and Linux, sending SIGTERM should suffice - process.kill(serverProcess.pid); - } + + switch (platform().toLowerCase()) { + //case "darwin": + // process.kill(serverProcess.pid); + // break; + //case "linux": + // process.kill(serverProcess.pid); + // break; + case "win32": + // For Windows, use taskkill to ensure all child processes are also terminated + spawn("taskkill", ["/pid", serverProcess.pid.toString(), "/f", "/t"]); + break; + + default: + console.log("Unhandled OS Platform: ", platform()); + serverProcess = null; + serverPath = null; + break; + } + } catch (error) { console.error(`Error killing server process: ${error}`); } From d90ac7cec053abd09128afbdb9caf42710c2970f Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Sat, 2 Mar 2024 11:44:23 +0100 Subject: [PATCH 20/45] get config when clicking settings --- gui/src/components/main.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/src/components/main.vue b/gui/src/components/main.vue index c63fdf7c..f37fafd4 100644 --- a/gui/src/components/main.vue +++ b/gui/src/components/main.vue @@ -20,7 +20,7 @@ import infoScreen from "./infoScreen.vue"; import main_modem_healthcheck from "./main_modem_healthcheck.vue"; import Dynamic_components from "./dynamic_components.vue"; -import { getFreedataMessages } from "../js/api"; +import { getFreedataMessages, getConfig } from "../js/api";