Skip to content

Commit

Permalink
fix: Address issues with loading the server on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderson1993 committed Sep 6, 2024
1 parent 32ad64d commit 8964ba7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion desktop/main/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ipcHandlers } from "./helpers/ipcHandlers";
import { autoUpdater } from "electron-updater";
import { initWin } from "./helpers/autoUpdate";
import { port } from "./helpers/settings";
import { ipAddress } from "@thorium/ipAddress";

let win: BrowserWindow | null = null;
app.enableSandbox();
Expand Down Expand Up @@ -78,7 +79,7 @@ async function createWindow() {
}
restoreMenubar(app);

await win.loadURL(`http://0.0.0.0:${port}`);
await win.loadURL(`http://${ipAddress}:${port}`);
}

app.whenReady().then(async () => {
Expand Down
5 changes: 3 additions & 2 deletions desktop/main/helpers/startThoriumServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fork, type ChildProcess } from "node:child_process";
import { hostSecret } from "../hostSecret";
import waitOn from "wait-on";
import { port } from "./settings";
import { ipAddress } from "@thorium/ipAddress";

let child: ChildProcess | null = null;
export async function startThoriumServer() {
Expand Down Expand Up @@ -39,7 +40,7 @@ export async function startThoriumServer() {
});

await waitOn({
resources: [`http://0.0.0.0:${port}/healthcheck`],
resources: [`http://${ipAddress}:${port}/healthcheck`],
});
}

Expand All @@ -54,7 +55,7 @@ app.on("before-quit", async (event) => {
export async function stopThoriumServer() {
if (child) {
await Promise.race([
fetch(`http://0.0.0.0:${port}/snapshot`, { method: "POST" }),
fetch(`http://${ipAddress}:${port}/snapshot`, { method: "POST" }),
new Promise((res) => setTimeout(res, 5000)),
]);
child.kill();
Expand Down
1 change: 0 additions & 1 deletion server/src/classes/Plugins/ShipSystems/Shields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function getWhichShield(
if (max === Math.abs(z) && z < 0) return "aft";
if (max === Math.abs(y) && y > 0) return "ventral";
if (max === Math.abs(y) && y < 0) return "dorsal";
console.log("No shield direction found");
// Default to fore in the very unlikely event that the direction is 0,0,0
return "fore";
}
5 changes: 3 additions & 2 deletions server/src/utils/appPaths.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";

export let __dirname =
process.env.NODE_ENV === "production"
? path.join(path.dirname(new URL(import.meta.url).pathname), "..")
: path.join(new URL(import.meta.url).pathname, "../../../..");
? path.join(fileURLToPath(new URL(".", import.meta.url)), "..")
: path.join(fileURLToPath(new URL(".", import.meta.url)), "../../..");

__dirname = __dirname.replaceAll("%20", " ");

Expand Down

0 comments on commit 8964ba7

Please sign in to comment.