Fixed: Inference-service plugin not working on win32 (#246)

* fix: inference service does not work on win32

* chore: fix path on windows

* chore: fix win32 working directory

* add nitron.exe for windows

---------

Co-authored-by: Louis <louis@jan.ai>
Co-authored-by: Hien To <tominhhien97@gmail.com>
This commit is contained in:
hiento09 2023-10-02 15:12:02 +07:00 committed by GitHub
parent 6500d0dca0
commit 34103b9701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 4 deletions

View File

@ -12,8 +12,11 @@ module.exports = {
],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
quotes: ["error", "single"],
"react/prop-types": "off", // In favor of strong typing - no need to dedupe
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
},
settings: {
react: {

View File

@ -2,6 +2,7 @@ const path = require("path");
const { app, dialog } = require("electron");
const { spawn } = require("child_process");
const fs = require("fs");
var exec = require("child_process").exec;
let subprocess = null;
@ -34,10 +35,10 @@ async function initModel(product) {
killSubprocess();
}
let binaryFolder = `${__dirname}/nitro`; // Current directory by default
let binaryFolder = path.join(__dirname, "nitro"); // Current directory by default
// Read the existing config
const configFilePath = `${binaryFolder}/config/config.json`;
const configFilePath = path.join(binaryFolder, "config", "config.json");
let config = {};
if (fs.existsSync(configFilePath)) {
const rawData = fs.readFileSync(configFilePath, "utf-8");
@ -56,8 +57,13 @@ async function initModel(product) {
// Write the updated config back to the file
fs.writeFileSync(configFilePath, JSON.stringify(config, null, 4));
const binaryPath =
process.platform === "win32"
? path.join(binaryFolder, "nitro.exe")
: path.join(binaryFolder, "nitro");
// Execute the binary
subprocess = spawn(`${binaryFolder}/nitro`, [configFilePath]);
subprocess = spawn(binaryPath, [configFilePath], {cwd: binaryFolder});
// Handle subprocess output
subprocess.stdout.on("data", (data) => {

Binary file not shown.

Binary file not shown.