Ejemplo n.º 1
0
func (registrar *Registrar) updateRegistrationBasedOnHealthCheck(client *gibson.CFRouterClient) {
	current := registrar.HealthChecker.Check()
	if (!current) && registrar.previousHealthStatus {
		registrar.logger.Info("Health check status changed to unavailabile; unregistering the route")
		client.Unregister(registrar.Config.Port, registrar.Config.ExternalHost)
	} else if current && (!registrar.previousHealthStatus) {
		registrar.logger.Info("Health check status changed to availabile; registering the route")
		client.Register(registrar.Config.Port, registrar.Config.ExternalHost)
	}
	registrar.previousHealthStatus = current
}
Ejemplo n.º 2
0
func (registrar *Registrar) registerSignalHandler(done chan bool, client *gibson.CFRouterClient) {
	go func() {
		select {
		case <-registrar.SignalChannel:
			registrar.logger.Info("Received SIGTERM or SIGINT; unregistering the route")
			client.Unregister(registrar.Config.Port, registrar.Config.ExternalHost)
			done <- true
		}
	}()

	signal.Notify(registrar.SignalChannel, syscall.SIGINT, syscall.SIGTERM)
}