Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Kill nitro process with API - nitro 0.1.27 #975

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extensions/inference-nitro-extension/bin/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.26
0.1.27
15 changes: 9 additions & 6 deletions extensions/inference-nitro-extension/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const NITRO_HTTP_SERVER_URL = `http://${LOCAL_HOST}:${PORT}`;
const NITRO_HTTP_LOAD_MODEL_URL = `${NITRO_HTTP_SERVER_URL}/inferences/llamacpp/loadmodel`;
const NITRO_HTTP_UNLOAD_MODEL_URL = `${NITRO_HTTP_SERVER_URL}/inferences/llamacpp/unloadModel`;
const NITRO_HTTP_VALIDATE_MODEL_URL = `${NITRO_HTTP_SERVER_URL}/inferences/llamacpp/modelstatus`;
const NITRO_HTTP_KILL_URL = `${NITRO_HTTP_SERVER_URL}/processmanager/destroy`;

// The subprocess instance for Nitro
let subprocess = null;
Expand Down Expand Up @@ -188,9 +189,14 @@ async function validateModelStatus(): Promise<ModelOperationResponse> {
*/
function killSubprocess(): Promise<void> {
if (subprocess) {
hiro-v marked this conversation as resolved.
Show resolved Hide resolved
subprocess.kill();
subprocess = null;
console.debug("Subprocess terminated.");
fetch(NITRO_HTTP_KILL_URL, {
method: "DELETE",
}).catch((err) => {
console.error(err);
subprocess.kill();
subprocess = null;
return killSubprocess();
});
hiro-v marked this conversation as resolved.
Show resolved Hide resolved
} else {
return kill(PORT, "tcp").then(console.log).catch(console.log);
}
Expand All @@ -207,9 +213,6 @@ async function checkAndUnloadNitro() {
// Attempt to unload model
return fetch(NITRO_HTTP_UNLOAD_MODEL_URL, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
}).catch((err) => {
console.error(err);
// Fallback to kill the port
Expand Down
Loading