MCPcopy Create free account
hub / github.com/FlashpointProject/launcher / restart

Method restart

src/back/ManagedChildProcess.ts:163–182  ·  view source on GitHub ↗

Restart the managed child process (by killing the current, and spawning a new).

()

Source from the content-addressed store, hash-verified

161
162 /** Restart the managed child process (by killing the current, and spawning a new). */
163 public async restart(): Promise<void> {
164 if (this.process && !this._isRestarting) {
165 this.setState(ProcessState.KILLING);
166 this._isRestarting = true;
167 this.logContent(`Restarting ${this.name} process`);
168 // Replace all listeners with a single listener waiting for the process to exit
169 this.process.removeAllListeners();
170 this.process.once('exit', (code, signal) => {
171 if (code) { this.logContent(`Old ${this.name} exited with code ${code}`); }
172 else { this.logContent(`Old ${this.name} exited with signal ${signal}`); }
173 this._isRestarting = false;
174 this.spawn();
175 });
176 // Kill process
177 await this.treeKill(this.process.pid);
178 this.process = undefined;
179 } else {
180 this.spawn();
181 }
182 }
183
184 private treeKill = async (PID: number): Promise<void> => {
185 await new Promise<void>((resolve, reject) => {

Callers

nothing calls this directly

Calls 4

setStateMethod · 0.95
logContentMethod · 0.95
spawnMethod · 0.95
onceMethod · 0.65

Tested by

no test coverage detected