mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-11 01:43:05 +00:00
enables process-control to try stopping codex with sigterm when sigint fails to stop it.
This commit is contained in:
parent
df9569314f
commit
79ca49b516
@ -47,6 +47,7 @@ export const mockOsService = {
|
||||
getWorkingDir: vi.fn(),
|
||||
listProcesses: vi.fn(),
|
||||
stopProcess: vi.fn(),
|
||||
terminateProcess: vi.fn(),
|
||||
};
|
||||
|
||||
export const mockCodexGlobals = {
|
||||
|
||||
@ -25,9 +25,25 @@ export class ProcessControl {
|
||||
if (processes.length < 1) throw new Error("No codex process found");
|
||||
|
||||
const pid = processes[0].pid;
|
||||
await this.stopProcess(pid);
|
||||
};
|
||||
|
||||
stopProcess = async (pid) => {
|
||||
this.os.stopProcess(pid);
|
||||
await this.sleep();
|
||||
};
|
||||
|
||||
if (await this.isProcessRunning(pid)) {
|
||||
this.os.terminateProcess(pid);
|
||||
await this.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
isProcessRunning = async (pid) => {
|
||||
const processes = await this.os.listProcesses();
|
||||
const p = processes.filter((p) => p.pid == pid);
|
||||
const result = p.length > 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
startCodexProcess = async () => {
|
||||
await this.saveCodexConfigFile();
|
||||
|
||||
@ -29,4 +29,8 @@ export class OsService {
|
||||
stopProcess = (pid) => {
|
||||
process.kill(pid, "SIGINT");
|
||||
};
|
||||
|
||||
terminateProcess = (pid) => {
|
||||
process.kill(pid, "SIGTERM");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user