feat: Cancelling session should close associated spawned proc

This commit is contained in:
Susmitha Girumala committed 2021-05-07 15:31:32 -04:00
1 parent 99125dbb77
commit 2f12cc91f2
5 files changed
+26 -4

No files matched your search

@@ -11,6 +11,7 @@ export default class ScopesScopeProjectsSessionsRoute extends Route {
// =services
@service ipc;
@service session;
// =attributes
@@ -83,5 +84,10 @@ export default class ScopesScopeProjectsSessionsRoute extends Route {
@notifySuccess('notifications.canceled-success')
async cancelSession(session) {
await session.cancelSession();
try {
this.ipc.invoke('cancel', { session_id: session.id });
} catch (e) {
//Ignore errors
}
}
}
@@ -1,8 +1,13 @@
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { notifySuccess, notifyError } from 'core/decorators/notify';
export default class ScopesScopeProjectsTargetsTargetSessionsRoute extends Route {
// =services
@service ipc;
// =actions
/**
@@ -14,5 +19,10 @@ export default class ScopesScopeProjectsTargetsTargetSessionsRoute extends Route
@notifySuccess('notifications.canceled-success')
async cancelSession(session) {
await session.cancelSession();
try {
this.ipc.invoke('cancel', { session_id: session.id });
} catch (e) {
//Ignore errors
}
}
}
@@ -53,6 +53,5 @@ module.exports = {
? `CLI Version: ${versionNumber}\nCLI Commit: ${gitRevision}`
: `CLI Commit: ${gitRevision}`;
return { gitRevision, versionNumber, formatted };
return rawOutput;
},
};
+9 -1
View File
@@ -2,7 +2,8 @@ const { shell } = require('electron');
const isDev = require('electron-is-dev');
const handle = require('./ipc-handler');
const boundaryCli = require('./boundary-cli');
const origin = require('./origin.js');
const origin = require('./origin');
const spawnSession = require('./spawn-session');
/**
* Returns the current runtime origin, which is used by the main thread to
@@ -58,3 +59,10 @@ handle('cliExists', () => boundaryCli.exists());
handle('connect', ({ target_id, token, host_id }) =>
boundaryCli.connect(target_id, token, host_id)
);
/**
* Cancel an established boundary session spawned process.
*/
handle('cancel', ({ session_id }) => {
spawnSession.cancelSession(session_id);
});
+1 -2
View File
@@ -5,7 +5,7 @@ const spawnedSessions = [];
const purge = (process_id, index) => {
process.kill(process_id);
// Remove tracking after cancellation
delete spawnedSessions[index];
spawnedSessions.splice(index, 1);
};
module.exports = {
@@ -15,7 +15,6 @@ module.exports = {
* @param {object} params
*/
add: ({ childProcess, data }) => {
debugger;
spawnedSessions.push({
data,
process_id: childProcess.pid,