mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-07 19:36:33 +00:00
kill daemon on app shutdown
This commit is contained in:
parent
6d1e486518
commit
b9f5f251af
@ -1,5 +1,5 @@
|
|||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import { exec } from 'child_process';
|
import { exec, ChildProcess } from 'child_process';
|
||||||
import { join, resolve } from 'path';
|
import { join, resolve } from 'path';
|
||||||
import { inject, injectable, named } from 'inversify';
|
import { inject, injectable, named } from 'inversify';
|
||||||
import { ILogger } from '@theia/core/lib/common/logger';
|
import { ILogger } from '@theia/core/lib/common/logger';
|
||||||
@ -20,6 +20,8 @@ export class ArduinoDaemon implements BackendApplicationContribution {
|
|||||||
@inject(ToolOutputServiceServer)
|
@inject(ToolOutputServiceServer)
|
||||||
protected readonly toolOutputService: ToolOutputServiceServer;
|
protected readonly toolOutputService: ToolOutputServiceServer;
|
||||||
|
|
||||||
|
protected process: ChildProcess | undefined;
|
||||||
|
|
||||||
protected isReady = new Deferred<boolean>();
|
protected isReady = new Deferred<boolean>();
|
||||||
|
|
||||||
async onStart() {
|
async onStart() {
|
||||||
@ -46,6 +48,8 @@ export class ArduinoDaemon implements BackendApplicationContribution {
|
|||||||
if (daemon.stderr) {
|
if (daemon.stderr) {
|
||||||
daemon.on('exit', (code, signal) => DaemonLog.log(this.logger, `Daemon exited with code: ${code}. Signal was: ${signal}.`));
|
daemon.on('exit', (code, signal) => DaemonLog.log(this.logger, `Daemon exited with code: ${code}. Signal was: ${signal}.`));
|
||||||
}
|
}
|
||||||
|
this.process = daemon;
|
||||||
|
|
||||||
await new Promise((resolve, reject) => setTimeout(resolve, 2000));
|
await new Promise((resolve, reject) => setTimeout(resolve, 2000));
|
||||||
this.isReady.resolve();
|
this.isReady.resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -53,4 +57,13 @@ export class ArduinoDaemon implements BackendApplicationContribution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onStop() {
|
||||||
|
if (!this.process) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DaemonLog.log(this.logger, `Shutting down daemon.`);
|
||||||
|
this.process.kill("SIGTERM");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user