github.com/wfusion/gofusion@v1.1.14/common/infra/asynq/signals_windows.go (about)

     1  //go:build windows
     2  // +build windows
     3  
     4  package asynq
     5  
     6  import (
     7  	"os"
     8  	"os/signal"
     9  
    10  	"golang.org/x/sys/windows"
    11  )
    12  
    13  // waitForSignals waits for signals and handles them.
    14  // It handles SIGTERM and SIGINT.
    15  // SIGTERM and SIGINT will signal the process to exit.
    16  //
    17  // Note: Currently SIGTSTP is not supported for windows build.
    18  func (srv *Server) waitForSignals() {
    19  	srv.logger.Info("[Common] asynq send signal TERM or INT to terminate the process")
    20  	sigs := make(chan os.Signal, 1)
    21  	signal.Notify(sigs, windows.SIGTERM, windows.SIGINT)
    22  	<-sigs
    23  }
    24  
    25  func (s *Scheduler) waitForSignals() {
    26  	s.logger.Info("[Common] asynq send signal TERM or INT to stop the scheduler")
    27  	sigs := make(chan os.Signal, 1)
    28  	signal.Notify(sigs, windows.SIGTERM, windows.SIGINT)
    29  	<-sigs
    30  }