Skip to content

interrupt handler attempts to get IPFSNode from client process while daemon is running #615

@btc

Description

@btc
485 // listen for and handle SIGTERM
486 func (i *cmdInvocation) setupInterruptHandler() {
487
488     ctx := i.req.Context()
489     sig := allInterruptSignals()
490
491     go func() {
492         // first time, try to shut down.
493
494         // loop because we may be
495         for count := 0; ; count++ {
496             <-sig
497
498             n, err := ctx.GetNode() // shouldn't be accessed from client process
499             if err != nil {
500                 log.Error(err)
501                 log.Critical("Received interrupt signal, terminating...")
502                 os.Exit(-1)
503             }
504
505             switch count {
506             case 0:
507                 log.Critical("Received interrupt signal, shutting down...")
508                 go func() {
509                     n.Close()
510                     log.Info("Gracefully shut down.")
511                 }()
512
513             default:
514                 log.Critical("Received another interrupt before graceful shutdown, terminating...")
515                 os.Exit(-1)
516             }
517         }
518     }()
519 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions