fix: catch nitro exit process for a clearer message
This commit is contained in:
parent
8f76b7c3e0
commit
d0c44f70f1
@ -45,8 +45,6 @@ function initModel(modelFile: string): Promise<InitModelResponse> {
|
||||
.then(checkAndUnloadNitro)
|
||||
// 2. Spawn the Nitro subprocess
|
||||
.then(spawnNitroProcess)
|
||||
// 3. Wait until the port is used (Nitro http server is up)
|
||||
.then(() => tcpPortUsed.waitUntilUsed(PORT, 300, 30000))
|
||||
// 4. Load the model into the Nitro subprocess (HTTP POST request)
|
||||
.then(loadLLMModel)
|
||||
// 5. Check if the model is loaded successfully
|
||||
@ -165,7 +163,8 @@ function checkAndUnloadNitro() {
|
||||
* Using child-process to spawn the process
|
||||
* Should run exactly platform specified Nitro binary version
|
||||
*/
|
||||
function spawnNitroProcess() {
|
||||
async function spawnNitroProcess(): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
let binaryFolder = path.join(__dirname, "nitro"); // Current directory by default
|
||||
let binaryName;
|
||||
|
||||
@ -206,6 +205,11 @@ function spawnNitroProcess() {
|
||||
subprocess.on("close", (code) => {
|
||||
console.log(`child process exited with code ${code}`);
|
||||
subprocess = null;
|
||||
reject(`Nitro process exited. ${code ?? ""}`);
|
||||
});
|
||||
tcpPortUsed.waitUntilUsed(PORT, 300, 30000).then(() => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ export function useActiveModel() {
|
||||
console.debug('Init model: ', modelId)
|
||||
const path = join('models', model.name, modelId)
|
||||
const res = await initModel(path)
|
||||
if (res?.error && modelId === activeModel?.id) {
|
||||
if (res?.error && (!activeModel?.id || modelId === activeModel?.id)) {
|
||||
const errorMessage = `${res.error}`
|
||||
alert(errorMessage)
|
||||
setStateModel(() => ({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user