File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ import { makeTopLevelCommand } from "./commands/TopLevelCommand.ts";
1919import { registerInfoCommand } from "./commands/info.command.ts" ;
2020import { registerConfigCommand } from "./commands/config/config.command.ts" ;
2121
22+ let shutdownRequested = 0 ;
23+
2224async function collie ( ) {
2325 const program = makeTopLevelCommand ( )
2426 . name ( CLI )
@@ -99,9 +101,22 @@ if (import.meta.main) {
99101}
100102
101103function gracefulShutdown ( ) : void {
104+ shutdownRequested += 1 ;
105+
106+ if ( shutdownRequested == 1 ) {
107+ logWithBanner (
108+ "Interrupt received.\nPlease wait for collie shut down or data loss may occur.\nGracefully shutting down..." ,
109+ ) ;
110+ } else {
111+ logWithBanner (
112+ "Two interrupts received, collie will now exit. Data loss may occur." ,
113+ ) ;
114+ Deno . exit ( 143 ) ;
115+ }
116+ }
117+
118+ function logWithBanner ( msg : string ) {
102119 console . log ( "\n\n" ) ;
103- console . log (
104- "Interrupt received.\nPlease wait for collie shut down or data loss may occur.\nGracefully shutting down..." ,
105- ) ;
120+ console . log ( msg ) ;
106121 console . log ( "\n\n" ) ;
107122}
You can’t perform that action at this time.
0 commit comments