コード例 #1
0
ファイル: Program.cs プロジェクト: volkanx/dyndns53
        static void Main(string[] args)
        {
            IConfigHandler _configHandler = new AppConfigHandler();
            var config = _configHandler.GetConfig();
            IIpChecker _ipChecker = new AwsIpChecker();
            IAmazonRoute53 _amazonClient = new AmazonRoute53Client(config.Route53AccessKey, config.Route53SecretKey, RegionEndpoint.EUWest1);
            var dnsUpdater = new DnsUpdater(_configHandler, _ipChecker, _amazonClient);

            HostFactory.Run(x =>
            {
                x.Service<IScheduledTaskService>(s =>
                {
                    s.ConstructUsing(name => new DnsUpdateService(new SchedulerRegistry(new ScheduledTaskWorker(dnsUpdater))));
                    s.WhenStarted(tc => tc.Start());
                    s.WhenStopped(tc => tc.Stop());
                });

                x.RunAsLocalSystem();

                x.SetDisplayName("DynDns53 Service");
                x.SetServiceName("DynDns53");
                x.SetDescription("Updates AWS Route53 records with the current external IP of the system");

                x.StartAutomatically();

                x.EnableServiceRecovery(s =>
                {
                    s.RestartService(1);
                    s.RestartService(2);
                    s.RestartService(5);
                });
            });
        }
コード例 #2
0
ファイル: MethodHost.cs プロジェクト: volkanx/dyndns53
        public async Task<long> AsyncMethod()
        {
            IConfigHandler _configHandler = new AppConfigHandler();
            var config = _configHandler.GetConfig();

            IAmazonRoute53 _amazonClient = new AmazonRoute53Client(config.Route53AccessKey, config.Route53SecretKey, RegionEndpoint.EUWest1);
            var request = new GetHealthCheckCountRequest() { };
            var response = await _amazonClient.GetHealthCheckCountAsync(request);

            return response.HealthCheckCount;
        }