@@ -342,6 +342,12 @@ func server() *cobra.Command {
342
342
return xerrors .Errorf ("notify systemd: %w" , err )
343
343
}
344
344
345
+ // Because the graceful shutdown includes cleaning up workspaces in dev mode, we're
346
+ // going to make it harder to accidentally skip the graceful shutdown by hitting ctrl+c
347
+ // two or more times. So the stopChan is unlimited in size and we don't call
348
+ // signal.Stop() until graceful shutdown finished--this means we swallow additional
349
+ // SIGINT after the first. To get out of a graceful shutdown, the user can send SIGQUIT
350
+ // with ctrl+\ or SIGTERM with `kill`.
345
351
stopChan := make (chan os.Signal , 1 )
346
352
defer signal .Stop (stopChan )
347
353
signal .Notify (stopChan , os .Interrupt )
@@ -358,12 +364,13 @@ func server() *cobra.Command {
358
364
return err
359
365
case <- stopChan :
360
366
}
361
- signal .Stop (stopChan )
362
367
_ , err = daemon .SdNotify (false , daemon .SdNotifyStopping )
363
368
if err != nil {
364
369
return xerrors .Errorf ("notify systemd: %w" , err )
365
370
}
366
- _ , _ = fmt .Fprintln (cmd .OutOrStdout (), "\n \n " + cliui .Styles .Bold .Render ("Interrupt caught. Gracefully exiting..." ))
371
+ _ , _ = fmt .Fprintln (cmd .OutOrStdout (), "\n \n " +
372
+ cliui .Styles .Bold .Render (
373
+ "Interrupt caught, gracefully exiting. Use ctrl+\\ to force quit" ))
367
374
368
375
if dev {
369
376
organizations , err := client .OrganizationsByUser (cmd .Context (), codersdk .Me )
0 commit comments