From 5f66f113afd28b547277b4eef9e4343e27fc6644 Mon Sep 17 00:00:00 2001 From: Srinath Narayanan Date: Wed, 30 Jun 2021 04:21:42 -0700 Subject: [PATCH] Added container unprovisioning --- src/Explorer/Explorer.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 38ebe1403..27c0e9cb2 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -477,6 +477,21 @@ export default class Explorer { }, body: JSON.stringify(provisionData) }) + const websocketId = await response.text(); + const unprovisionData = { + resourceId: userContext.databaseAccount.id, + websocketId: websocketId + } + + window.addEventListener("beforeunload", async () => { + const response = await window.fetch("http://localhost:443/api/containerpooling/unprovision", { + method: "POST", + headers: { + [HttpHeaders.contentType]: "application/json", + }, + body: JSON.stringify(unprovisionData) + }) + }) this.notebookServerInfo({ notebookServerEndpoint: userContext.features.notebookServerUrl || `http://localhost:443/api/containerpooling/resid${userContext.databaseAccount.id}/forward/`,