-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dummyFunction properly fails when backend isn't running
- Loading branch information
Showing
3 changed files
with
21 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import { server } from "./server"; | ||
export function dummyFunction() { | ||
return server!.callPluginMethod<{}, boolean>("dummy_function", {}); | ||
export async function dummyFunction() { | ||
try { | ||
return await server!.callPluginMethod<{}, boolean>("dummy_function", {}); | ||
} catch { | ||
// If backend is not running, fetch fails | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { Command } from "@tauri-apps/api/shell"; | ||
import { dummyFunction } from "backend/pythonMethods"; | ||
export async function startBackend(onClose: any = () => {}) { | ||
const command = new Command("startBackend", [ | ||
"Start-Process", | ||
"-FilePath", | ||
"([Environment]::GetFolderPath('Startup')", | ||
"+", | ||
"'\\CssLoader-Standalone-Headless.exe')", | ||
]); | ||
command.on("close", onClose); | ||
await command.spawn(); | ||
const isRunning = await dummyFunction(); | ||
if (!isRunning) { | ||
const command = new Command("startBackend", [ | ||
"Start-Process", | ||
"-FilePath", | ||
"([Environment]::GetFolderPath('Startup')", | ||
"+", | ||
"'\\CssLoader-Standalone-Headless.exe')", | ||
]); | ||
command.on("close", onClose); | ||
await command.spawn(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters