Ejemplo n.º 1
0
func CatchSignals(room *Room) {
	for {
		signal := <-signal.Incoming

		signal_parts := strings.Split(signal.String(), ":", 2)
		signal_name := signal_parts[0]
		log.Printf("Signal name: %s\n", signal_name)
		for _, name := range caught_signals {
			if name == signal_name {
				log.Printf("%s - Leave all rooms!\n", name)
				room.Leave()
				log.Fatal("Received interupt")
			}
		}
		log.Printf("Signal: %s\n", signal.String())
	}
}
Ejemplo n.º 2
0
func CatchSignals(room *Room) {
	for {
		signal := <-signal.Incoming

		signal_parts := strings.SplitN(signal.String(), ":", 2)
		signal_name := signal_parts[0]
		log.Printf("Signal name: %s\n", signal_name)
		for _, name := range caught_signals {
			if name == signal_name {
				log.Printf("%s - Leave all rooms!\n", name)
				room.TextMessage("I've been told to die - bye bye cruel world :(")
				room.Leave()
				log.Fatal("Received interupt")
			}
		}
		log.Printf("Signal: %s\n", signal.String())
	}
}
Ejemplo n.º 3
0
func SignalHandler() {
	c := make(chan os.Signal, 1)
	// Signal für CTRL-C abfangen...
	signal.Notify(c, syscall.SIGINT)

	// foreach signal received
	for signal := range c {
		fmt.Println("\nSignal empfangen...")
		fmt.Println(signal.String())
		switch signal {
		case syscall.SIGINT:
			os.Exit(0)
		}
	}
}
Ejemplo n.º 4
0
func signalCatcher() {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGHUP)
	signal.Notify(ch, syscall.SIGINT)
	signal.Notify(ch, syscall.SIGTERM)
	var msg string
	select {
	case signal := <-ch:
		msg = signal.String()
	case <-Reservoir_Shutdown:
		msg = "normal call to shutdown"
	}
	log.Printf("received \"%s\", exiting.", msg)
	exitHandler.OnExit()
	os.Exit(0)
}
Ejemplo n.º 5
0
func SignalHandlerMitChannel(q chan bool) {
	var quit bool

	c := make(chan os.Signal, 1)
	// Signal für CTRL-C abfangen...
	signal.Notify(c, syscall.SIGINT)

	// foreach signal received
	for signal := range c {
		fmt.Println("\nSignal empfangen...")
		fmt.Println(signal.String())
		switch signal {
		case syscall.SIGINT:
			quit = true
		}
		if quit {
			//TODO: Alles schließen!!!
			//os.Exit(0) // os.Exit() muss nicht sein, da das Hauptprogramm auf den Channel wartet.
		}
		// report the value of quit via the channel
		q <- quit
	}
}
Ejemplo n.º 6
0
func StartSignalListener() {
	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGUSR1, syscall.SIGUSR2, syscall.SIGINT, syscall.SIGKILL, syscall.SIGTERM)
	for {
		var signal = <-c
		log.Info("SYSTEM: SIGNAL %s RECEIVED", signal.String())
		switch signal {
		case syscall.SIGUSR1:
			ReloadConfig(flags.MainConfigFilePath)
		case syscall.SIGUSR2:
			FlushQueues()
		case syscall.SIGINT:
			GracefullyStop()
		case syscall.SIGKILL:
			GracefullyStop()
		case syscall.SIGTERM:
			GracefullyStop()
		case syscall.SIGHUP:
			GracefullyStop()
		}

	}
}