File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments