Пример #1
0
//----------------------------------------------- handle unix signals
func SignalProc() {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGHUP)

	for {
		msg := <-ch
		log.Println("Recevied signal:", msg)
		cfg.Reload()
	}
}
Пример #2
0
//----------------------------------------------- handle unix signals
func SignalProc() {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGHUP)
	for {
		msg := <-ch
		switch msg {
		case syscall.SIGHUP:
			log.Println("Recevied signal:", msg)
			cfg.Reload()
			/*
			   case syscall.SIGTREM:
			       atomic.StoreInt32(&SIGTREM,1)
			       wg.Wait()
			       os.Exit(-1)
			*/
		}
	}
}
Пример #3
0
//----------------------------------------------- handle unix signals
func SignalProc() {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGHUP, syscall.SIGTERM)

	for {
		msg := <-ch
		switch msg {
		case syscall.SIGHUP: // reload config
			log.Println("\033[043;1m[SIGHUP]\033[0m")
			cfg.Reload()
			gamedata.Reload()
		case syscall.SIGTERM: // server close
			close(die)
			log.Println("\033[043;1m[SIGTERM]\033[0m")
			INFO("waiting for agents close, please wait...")
			wg.Wait()
			INFO("all work done. bye bye!!!")
			os.Exit(0)
		}
	}
}