@@ -20,7 +20,6 @@ import (
20
20
"github.com/tarantool/tt/cli/process_utils"
21
21
"github.com/tarantool/tt/cli/ttlog"
22
22
"github.com/tarantool/tt/cli/util"
23
- "golang.org/x/net/context"
24
23
"gopkg.in/yaml.v2"
25
24
)
26
25
@@ -516,18 +515,19 @@ func FillCtx(cliOpts *config.CliOpts, cmdCtx *cmdcontext.CmdCtx,
516
515
517
516
// Start an Instance.
518
517
func Start (cmdCtx * cmdcontext.CmdCtx , run * InstanceCtx ) error {
519
- // Register a context, related with a signal handler that
520
- // removes a pid file if interrupt signals were sent before starting
521
- // an instance and watchdog signal handlers.
522
- sigCtx , stop := signal .NotifyContext (context .Background (),
518
+ // Register a signal handler that removes a pid file if interrupt
519
+ // signals were sent to the process before starting an instance
520
+ // and watchdog signal handlers.
521
+ signalChan := make (chan os.Signal , 1 )
522
+ signal .Notify (signalChan ,
523
523
syscall .SIGINT , syscall .SIGTERM )
524
524
if err := process_utils .CreatePIDFile (run .PIDFile ); err != nil {
525
525
return err
526
526
}
527
527
528
528
defer func () {
529
529
cleanup (run )
530
- stop ( )
530
+ signal . Stop ( signalChan )
531
531
}()
532
532
533
533
logger := createLogger (run )
@@ -537,9 +537,14 @@ func Start(cmdCtx *cmdcontext.CmdCtx, run *InstanceCtx) error {
537
537
// The Done() state of the context means that the process received
538
538
// an interrupt signal and there is a need to clean up the resources.
539
539
select {
540
- case <- sigCtx . Done () :
540
+ case <- signalChan :
541
541
return nil
542
542
default :
543
+ // Ignore function unregisters the current signal handler.
544
+ // SIGINT and SIGTERM signals will be ignored until the call of
545
+ // signal.Reset(), that will be done before the start of
546
+ // watchdog's signal handling loop.
547
+ signal .Ignore (syscall .SIGINT , syscall .SIGTERM )
543
548
wd .Start ()
544
549
}
545
550
return nil
0 commit comments