Skip to content

Commit c2a7812

Browse files
Zuoyuan Huanggoel-akas
authored andcommitted
Idle endpoint creates metadata file if not exist
**Description** * Idle endpoint creates metadata file if not exist **Motivation** * Fix the issue of space that has never been opened will not auto shutdown **Testing Done** * Build CE package **Backwards Compatibility Criteria (if any)** * N/A
1 parent 5353700 commit c2a7812

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

patches/sagemaker-idle-extension.patch

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,12 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
289289
===================================================================
290290
--- sagemaker-code-editor.orig/vscode/src/vs/server/node/webClientServer.ts
291291
+++ sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
292-
@@ -4,6 +4,7 @@
292+
@@ -3,7 +3,8 @@
293+
* Licensed under the MIT License. See License.txt in the project root for license information.
293294
*--------------------------------------------------------------------------------------------*/
294295

295-
import { createReadStream } from 'fs';
296+
-import { createReadStream } from 'fs';
297+
+import { createReadStream, existsSync, writeFileSync } from 'fs';
296298
+import {readFile } from 'fs/promises';
297299
import { Promises } from 'vs/base/node/pfs';
298300
import * as path from 'path';
@@ -323,7 +325,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
323325
if (pathname === this._callbackRoute) {
324326
// callback support
325327
return this._handleCallback(res);
326-
@@ -451,6 +457,23 @@ export class WebClientServer {
328+
@@ -451,6 +457,31 @@ export class WebClientServer {
327329
});
328330
return void res.end(data);
329331
}
@@ -335,6 +337,14 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
335337
+ try {
336338
+ const tmpDirectory = '/tmp/'
337339
+ const idleFilePath = path.join(tmpDirectory, '.sagemaker-last-active-timestamp');
340+
+
341+
+ // If idle shutdown file does not exist, this indicates the app UI may never been opened
342+
+ // Create the initial metadata file
343+
+ if (!existsSync(idleFilePath)) {
344+
+ const timestamp = new Date().toISOString();
345+
+ writeFileSync(idleFilePath, timestamp);
346+
+ }
347+
+
338348
+ const data = await readFile(idleFilePath, 'utf8');
339349
+
340350
+ res.statusCode = 200;

0 commit comments

Comments
 (0)