Exemplo n.º 1
0
        public void Handle(ServerStoppedResponding notification)
        {
            // TODO: should we wait a little bit more just to let CS start its work?
            var server = backupManager.GetNextServer();

            if (server != null)
            {
                logger.Error($"Primary CS is down, restoring connection to {server.Address}:{server.Port}.");
                cfgProvider.ChangeConfiguration(server.Address, server.Port);

                Task.Factory.StartNew(async() =>
                {
                    await Task.Delay(2000);
                    mediator.Publish(new ConnectionRestored());
                });
            }
            else
            {
                logger.Error("Primary CS is down but we don't have other backup servers, forcing exit");
                mediator.Send(new ShutdownSystem());
            }
        }