@@ -645,6 +645,7 @@ type empty = Record<string | number | symbol, never>;
645645type ServerCommand =
646646 | { type : "run" ; content : { file : string ; options : JuliaExecuteOptions } }
647647 | { type : "close" ; content : { file : string } }
648+ | { type : "forceclose" ; content : { file : string } }
648649 | { type : "isopen" ; content : { file : string } }
649650 | { type : "stop" ; content : empty }
650651 | { type : "isready" ; content : empty }
@@ -653,6 +654,7 @@ type ServerCommand =
653654type ServerCommandResponseMap = {
654655 run : { notebook : JupyterNotebook } ;
655656 close : { status : true } ;
657+ forceclose : { status : true } ;
656658 stop : { message : "Server stopped." } ;
657659 isopen : boolean ;
658660 isready : true ;
@@ -863,8 +865,13 @@ function populateJuliaEngineCommand(command: Command) {
863865 "Close the worker for a given notebook. If it is currently running, it will not be interrupted." ,
864866 )
865867 . arguments ( "<file:string>" )
866- . action ( async ( _ , file ) => {
867- await closeWorker ( file ) ;
868+ . option (
869+ "-f, --force" ,
870+ "Force closing. This will terminate the worker if it is running." ,
871+ { default : false } ,
872+ )
873+ . action ( async ( options , file ) => {
874+ await closeWorker ( file , options . force ) ;
868875 } )
869876 . command ( "stop" , "Stop the server" )
870877 . description (
@@ -961,13 +968,13 @@ async function connectAndWriteJuliaCommandToRunningServer<
961968 }
962969}
963970
964- async function closeWorker ( file : string ) {
971+ async function closeWorker ( file : string , force : boolean ) {
965972 const absfile = normalizePath ( file ) ;
966973 await connectAndWriteJuliaCommandToRunningServer ( {
967- type : "close" ,
974+ type : force ? "forceclose" : "close" ,
968975 content : { file : absfile } ,
969976 } ) ;
970- info ( " Worker closed successfully." ) ;
977+ info ( ` Worker ${ force ? "force-" : "" } closed successfully.` ) ;
971978}
972979
973980async function stopServer ( ) {
0 commit comments