agent/sighandlers/termination_handler.go
func StartDefaultTerminationHandler(saver statemanager.Saver, taskEngine engine.TaskEngine) {
	signalChannel := make(chan os.Signal, 2)
	signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)

	sig := <-signalChannel
	seelog.Debugf("Termination handler received termination signal: %s", sig.String())

	err := FinalSave(saver, taskEngine)
	if err != nil {
		seelog.Criticalf("Error saving state before final shutdown: %v", err)
		// Terminal because it's a sigterm; the user doesn't want it to restart
		os.Exit(exitcodes.ExitTerminal)
	}
	os.Exit(exitcodes.ExitSuccess)
}
func StartDefaultTerminationHandler(saver statemanager.Saver, taskEngine engine.TaskEngine) {
	signalChannel := make(chan os.Signal, 2)
	signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)

	sig := <-signalChannel
	seelog.Debugf("Termination handler received termination signal: %s", sig.String())

	err := FinalSave(saver, taskEngine)
	if err != nil {
		seelog.Criticalf("Error saving state before final shutdown: %v", err)
		// Terminal because it's a sigterm; the user doesn't want it to restart
		os.Exit(exitcodes.ExitTerminal)
	}
	os.Exit(exitcodes.ExitSuccess)
}
func StartDefaultTerminationHandler ( saver statemanager . Saver , taskEngine engine . TaskEngine ) { signalChannel := make ( chan os . Signal , 2 ) signal . Notify ( signalChannel , os . Interrupt , syscall . SIGTERM ) sig := <- signalChannel seelog . Debugf ( " " , sig . String ( ) ) err := FinalSave ( saver , taskEngine ) if err != nil { seelog . Criticalf ( " " , err ) // Terminal because it's a sigterm; the user doesn't want it to restart os . Exit ( exitcodes . ExitTerminal ) } os . Exit ( exitcodes . ExitSuccess ) }
// StartDefaultTerminationHandler defines a default termination handler suitable for running in a process
StartDefaultTerminationHandler defines a default termination handler suitable for running in a process