Skip to content

Commit 876e70f

Browse files
committed
change impl
1 parent 86f2530 commit 876e70f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

sandbox/mod.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export const sandboxCreateCommand = new Command<SandboxContext>()
8888
Deno.exit(status.code);
8989
}
9090

91+
const stopMessage = "Stopping the sandbox...";
9192
if (options.ssh) {
9293
const success = await sshIntoSandbox(sandbox);
93-
const stopMessage = "Stopping the sandbox...";
9494
if (success) {
9595
// Closes the sandbox only when ssh session was established and finished successfully
9696
await sandbox.close();
@@ -104,6 +104,14 @@ export const sandboxCreateCommand = new Command<SandboxContext>()
104104
Deno.exit();
105105
});
106106
}
107+
} else if (options.lifetime === "session") {
108+
// Otherwise, keep the sandbox running and wait for Ctrl+C
109+
console.log("\nCtrl+C to stop the sandbox.");
110+
Deno.addSignalListener("SIGINT", async () => {
111+
console.log("\n" + stopMessage);
112+
await sandbox.close();
113+
Deno.exit();
114+
});
107115
} else {
108116
console.log(sandbox.id);
109117

0 commit comments

Comments
 (0)