mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
SDA-4751 - Prevent starting new c9 shell if application is terminated (#2252)
* SDA-4751 - Prevent starting new c9 shell if application is terminated * SDA-4751 - Prevent c9 connect
This commit is contained in:
parent
812991045c
commit
db58320995
@ -1,7 +1,13 @@
|
||||
import { WebContents } from 'electron';
|
||||
import { app, WebContents } from 'electron';
|
||||
import { createConnection, Socket } from 'net';
|
||||
import { logger } from '../common/c9-logger';
|
||||
|
||||
let isAppQuitting = false;
|
||||
|
||||
app.on('before-quit', () => {
|
||||
isAppQuitting = true;
|
||||
});
|
||||
|
||||
class C9PipeHandler {
|
||||
private _socket: Socket | undefined;
|
||||
|
||||
@ -89,6 +95,12 @@ let c9PipeHandler: C9PipeHandler | undefined;
|
||||
* @param pipe pipe identifier
|
||||
*/
|
||||
export const connectC9Pipe = (sender: WebContents, pipe: string) => {
|
||||
if (isAppQuitting) {
|
||||
logger.info(
|
||||
'c9-pipe-handler: App is quitting, preventing c9 pipe connect.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!c9PipeHandler) {
|
||||
c9PipeHandler = new C9PipeHandler();
|
||||
} else {
|
||||
@ -104,6 +116,9 @@ export const connectC9Pipe = (sender: WebContents, pipe: string) => {
|
||||
* @param data the data to be written
|
||||
*/
|
||||
export const writeC9Pipe = (data: Uint8Array) => {
|
||||
if (isAppQuitting) {
|
||||
return;
|
||||
}
|
||||
c9PipeHandler?.write(data);
|
||||
};
|
||||
|
||||
|
@ -17,6 +17,12 @@ export interface IShellStatus {
|
||||
|
||||
type StatusCallback = (status: IShellStatus) => void;
|
||||
|
||||
let isAppQuitting = false;
|
||||
|
||||
app.on('before-quit', () => {
|
||||
isAppQuitting = true;
|
||||
});
|
||||
|
||||
class C9ShellHandler {
|
||||
private _c9shell: ChildProcess | undefined;
|
||||
private _curStatus: IShellStatus | undefined;
|
||||
@ -43,6 +49,12 @@ class C9ShellHandler {
|
||||
* Starts the c9shell process
|
||||
*/
|
||||
public async startShell() {
|
||||
if (isAppQuitting) {
|
||||
logger.info(
|
||||
'c9-shell-handler: App is quitting, preventing c9 shell start.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (this._attachExistingC9Shell()) {
|
||||
logger.info('c9-shell-handler: _attachExistingC9Shell, skip start');
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user