Skip to content

Commit

Permalink
Merge pull request #11161 from meeseeksmachine/auto-backport-of-pr-10…
Browse files Browse the repository at this point in the history
…843-on-3.0.x

Backport PR #10843 on branch 3.0.x (Shutdown sessions/terminals on shutdown)
  • Loading branch information
jasongrout authored Sep 28, 2021
2 parents 34b473d + 7193b25 commit 3814fbf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/mainmenu-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,23 @@ export function createFileMenu(
Dialog.cancelButton(),
Dialog.warnButton({ label: trans.__('Shut Down') })
]
}).then(result => {
}).then(async result => {
if (result.button.accept) {
const setting = ServerConnection.makeSettings();
const apiURL = URLExt.join(setting.baseUrl, 'api/shutdown');

// Shutdown all kernel and terminal sessions before shutting down the server
// If this fails, we continue execution so we can post an api/shutdown request
try {
await Promise.all([
app.serviceManager.sessions.shutdownAll(),
app.serviceManager.terminals.shutdownAll()
]);
} catch (e) {
// Do nothing
console.log(`Failed to shutdown sessions and terminals: ${e}`);
}

return ServerConnection.makeRequest(
apiURL,
{ method: 'POST' },
Expand Down

0 comments on commit 3814fbf

Please sign in to comment.