@@ -709,6 +709,10 @@ app.on('ready', async () => {
709
709
const userDataPath = getRealPath ( app . getPath ( 'userData' ) ) ;
710
710
const installPath = getRealPath ( join ( app . getAppPath ( ) , '..' , '..' ) ) ;
711
711
712
+ // Register signal handlers
713
+ process . on ( 'SIGINT' , ( ) => gracefulShutdown ( 'SIGINT' ) ) ; // Ctrl+C
714
+ process . on ( 'SIGTERM' , ( ) => gracefulShutdown ( 'SIGTERM' ) ) ; // Termination request
715
+
712
716
installFileHandler ( {
713
717
protocol : electronProtocol ,
714
718
userDataPath,
@@ -859,7 +863,7 @@ async function requestShutdown() {
859
863
setTimeout ( ( ) => {
860
864
console . log ( 'requestShutdown: Response never received; forcing shutdown.' ) ;
861
865
resolve ( undefined ) ;
862
- } , 2 * DURATION . MINUTES ) ;
866
+ } , 1 * DURATION . MINUTES ) ;
863
867
} ) ;
864
868
865
869
try {
@@ -869,6 +873,13 @@ async function requestShutdown() {
869
873
}
870
874
}
871
875
876
+ async function gracefulShutdown ( signal : string ) {
877
+ console . warn ( `Received ${ signal } , shutting down...` ) ;
878
+ await requestShutdown ( ) ;
879
+ app . quit ( ) ;
880
+ console . warn ( `Received ${ signal } , shutting down: done` ) ;
881
+ }
882
+
872
883
app . on ( 'before-quit' , ( ) => {
873
884
console . log ( 'before-quit event' , {
874
885
readyForShutdown : mainWindow ? readyForShutdown : null ,
0 commit comments