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