Exemplo n.º 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var config = _serviceConfig.Value;
            var server = new Server
            {
                Services = { EmailGenerator.BindService(_service) },
                Ports    = { new ServerPort(config.Host, config.Port, ServerCredentials.Insecure) }
            };

            server.Start();

            _logger.LogInformation("Email Generator is running on {Host}:{Port}.", config.Host, config.Port);
            await stoppingToken;

            _logger.LogWarning("Cancellation received. Shutting down Email Generator.");
            await server.ShutdownAsync();
        }