Exemple #1
0
func main() {
	flag.Parse()

	log.Printf("Configuration loaded from file: %s", configFilePath)
	config := configuration.Load(configFilePath)
	signal.Handle(func() {
		config = configuration.Load("config.json")
		log.Printf("Reloading configuration from: %s", configFilePath)
	})

	tickerChannel := time.NewTicker(time.Second * time.Duration(config.Interval)).C

	for {
		select {
		case <-tickerChannel:
			for _, redisConfig := range config.Redis {
				address := fmt.Sprintf("%s:%d", redisConfig.Host, redisConfig.Port)
				var name = ""
				if redisConfig.Alias != "" {
					name = redisConfig.Alias
				} else {
					name = redisConfig.Host
				}
				go info(address, name, config)
			}
		}
	}
}
Exemple #2
0
func Test_Handle_With2_SIGHUP_ExecutesFnTwice(t *testing.T) {
	done := make(chan bool, 1)
	signal.Handle(func() {
		done <- true
	})
	syscall.Kill(syscall.Getpid(), syscall.SIGHUP)
	receiveOnce(t, done)
	syscall.Kill(syscall.Getpid(), syscall.SIGHUP)
	receiveOnce(t, done)
}