Skip to content

Commit

Permalink
Avoid indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoli committed Sep 1, 2023
1 parent 3cf484d commit 20ef432
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
34 changes: 17 additions & 17 deletions src/toolbox/serverManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,25 +165,25 @@ export class ServerManager {
this.log(`Kill server process ${this.proc?.pid}.`);
const proc = this.proc as childProcess.ChildProcessWithoutNullStreams;
proc.removeListener("exit", this.procExitCallback);
if (proc.pid !== undefined) {
treeKill(proc.pid, "SIGKILL", (err) => {
if (err) {
this.log(`Failed to kill process tree of ${proc.pid}: ${err}`);
const succeeded = proc.kill("SIGKILL");
if (!succeeded) {
this.log(`Failed to kill process ${proc.pid}.`);
}
this.log("This is an unrecorevable error.");
this.setState(State.Unrecoverable);
} else {
// Success
this.proc = undefined;
this.setState(State.Stopped);
}
});
} else {
if (proc.pid === undefined) {
this.log("The process id is undefined.");
return;
}
treeKill(proc.pid, "SIGKILL", (err) => {
if (err) {
this.log(`Failed to kill process tree of ${proc.pid}: ${err}`);
const succeeded = proc.kill("SIGKILL");
if (!succeeded) {
this.log(`Failed to kill process ${proc.pid}.`);
}
this.log("This is an unrecorevable error.");
this.setState(State.Unrecoverable);
} else {
// Success
this.proc = undefined;
this.setState(State.Stopped);
}
});
} else {
this.proc = undefined;
this.setState(State.Stopped);
Expand Down
28 changes: 14 additions & 14 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,21 @@ export function spawn(
if (!status.killed) {
status.killed = true;
// TODO: Try with SIGTERM before.
if (proc.pid !== undefined) {
treeKill(proc.pid, "SIGKILL", (err) => {
if (err) {
log(`Failed to kill process tree of ${proc.pid}: ${err}`);
const succeeded = proc.kill("SIGKILL");
if (!succeeded) {
log(`Failed to kill process ${proc.pid}.`);
}
} else {
log(`Process ${proc.pid} has been killed successfully.`);
}
});
} else {
log(`The process id is undefined.`);
if (proc.pid === undefined) {
log("The process id is undefined.");
return;
}
treeKill(proc.pid, "SIGKILL", (err) => {
if (err) {
log(`Failed to kill process tree of ${proc.pid}: ${err}`);
const succeeded = proc.kill("SIGKILL");
if (!succeeded) {
log(`Failed to kill process ${proc.pid}.`);
}
} else {
log(`Process ${proc.pid} has been killed successfully.`);
}
});
} else {
log(`Process ${proc.pid} has already been killed.`);
}
Expand Down

0 comments on commit 20ef432

Please sign in to comment.