diff --git a/app/utils/local/cleanup.js b/app/utils/local/cleanup.js index a11dbfc0..a7430d0f 100644 --- a/app/utils/local/cleanup.js +++ b/app/utils/local/cleanup.js @@ -39,8 +39,7 @@ function killHttpMicroservice(microservice) { const failMessage = `Failed to kill ${microservice.name}`; async function do_kill() { try { - const fetchFunc = typeof $fetch === "undefined" ? fetch : $fetch; - await fetchFunc(microservice.url, { + await fetch(microservice.url, { method: microservice.method, }); } catch (error) { diff --git a/app/utils/local/microservices.js b/app/utils/local/microservices.js index ba726b2c..7bddec7e 100644 --- a/app/utils/local/microservices.js +++ b/app/utils/local/microservices.js @@ -7,18 +7,13 @@ import path from "node:path"; import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type: "json" }; // Local imports -import { commandExistsSync, getAvailablePort, waitForReady } from "./scripts.js"; +import { getAvailablePort, waitForReady } from "./scripts.js"; import { microservicesMetadatasPath, projectMicroservices } from "./cleanup.js"; import { executablePath } from "./path.js"; const MILLISECONDS_PER_SECOND = 1000; const DEFAULT_TIMEOUT_SECONDS = 30; -function resolveCommand(execPath, execName) { - const command = commandExistsSync(execName) ? execName : executablePath(execPath, execName); - return command; -} - async function runScript( execPath, execName, @@ -26,7 +21,7 @@ async function runScript( expectedResponse, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS, ) { - const command = resolveCommand(execPath, execName); + const command = executablePath(execPath, execName); console.log("runScript", command, args); const child = child_process.spawn(command, args, { @@ -69,7 +64,7 @@ async function runBack(execName, execPath, args = {}) { const backArgs = [ "--port", String(port), - "--data_folder_path", + "--project_folder_path", projectFolderPath, "--upload_folder_path", uploadFolderPath, @@ -95,7 +90,7 @@ async function runViewer(execName, execPath, args = {}) { const viewerArgs = [ "--port", String(port), - "--data_folder_path", + "--project_folder_path", projectFolderPath, "--timeout", "0", diff --git a/app/utils/local/path.js b/app/utils/local/path.js index dcf90343..22c67984 100644 --- a/app/utils/local/path.js +++ b/app/utils/local/path.js @@ -9,25 +9,31 @@ import { v4 as uuidv4 } from "uuid"; // Local imports import { appMode } from "./app_mode.js"; +import { commandExistsSync } from "./scripts.js"; function executablePath(execPath, execName) { + const osExecutableName = executableName(execName); const resourcesPath = process.env.RESOURCES_PATH; const mode = process.env.MODE; const nodeEnv = process.env.NODE_ENV; console.log("[executablePath]", { execPath, execName, mode, nodeEnv, resourcesPath }); if (mode === appMode.DESKTOP && nodeEnv === "production") { - const execPathInResources = path.join(resourcesPath, executableName(execName)); + const execPathInResources = path.join(resourcesPath, osExecutableName); if (fs.existsSync(execPathInResources)) { console.log(`[executablePath] Found executable in resources path: ${execPathInResources}`); return execPathInResources; } } - const localExecPath = path.join(execPath, executableName(execName)); + const localExecPath = path.join(execPath, osExecutableName); if (fs.existsSync(localExecPath)) { console.log(`[executablePath] Found executable in local path: ${localExecPath}`); return localExecPath; } - throw new Error(`Executable not found: ${execName}`); + if (commandExistsSync(osExecutableName)) { + console.log(`[executablePath] Found executable in PATH: ${osExecutableName}`); + return osExecutableName; + } + throw new Error(`Executable not found: ${osExecutableName}`); } function executableName(execName) {