예제 #1
0
        static void Main()
        {
            XmlConfigurator.Configure();

            HostFactory.Run(hostConfiguration =>
            {
                hostConfiguration.RunAsLocalSystem();
                hostConfiguration.SetDescription("EasyNetQ.Scheduler");
                hostConfiguration.SetDisplayName("EasyNetQ.Scheduler");
                hostConfiguration.SetServiceName("EasyNetQ.Scheduler");

                hostConfiguration.Service <ISchedulerService>(serviceConfiguration =>
                {
                    serviceConfiguration.ConstructUsing(_ => SchedulerServiceFactory.CreateScheduler());

                    serviceConfiguration.WhenStarted((service, _) =>
                    {
                        service.Start();
                        return(true);
                    });
                    serviceConfiguration.WhenStopped((service, _) =>
                    {
                        service.Stop();
                        return(true);
                    });
                });
            });
        }
예제 #2
0
        static void Main()
        {
            XmlConfigurator.Configure();

            HostFactory.Run(hostConfiguration =>
            {
                hostConfiguration.EnableServiceRecovery(serviceRecoveryConfiguration =>
                {
                    serviceRecoveryConfiguration.RestartService(delayInMinutes: 1); // On the first service failure, reset service after a minute
                    serviceRecoveryConfiguration.SetResetPeriod(days: 0);           // Reset failure count after every failure
                });
                hostConfiguration.RunAsLocalSystem();
                hostConfiguration.SetDescription("EasyNetQ.Scheduler");
                hostConfiguration.SetDisplayName("EasyNetQ.Scheduler");
                hostConfiguration.SetServiceName("EasyNetQ.Scheduler");

                hostConfiguration.Service <ISchedulerService>(serviceConfiguration =>
                {
                    serviceConfiguration.ConstructUsing(_ => SchedulerServiceFactory.CreateScheduler());

                    serviceConfiguration.WhenStarted((service, _) =>
                    {
                        service.Start();
                        return(true);
                    });
                    serviceConfiguration.WhenStopped((service, _) =>
                    {
                        service.Stop();
                        return(true);
                    });
                });
            });
        }
예제 #3
0
파일: Program.cs 프로젝트: nslowes/EasyNetQ
        static void Main()
        {
            XmlConfigurator.Configure();

            HostFactory.Run(hostConfiguration =>
            {
                hostConfiguration.AfterStartingServices(() => Console.WriteLine("Started EasyNetQ.Scheduler"));
                hostConfiguration.AfterStoppingServices(() => Console.WriteLine("Stopped EasyNetQ.Scheduler"));
                // hostConfiguration.EnableDashboard();
                hostConfiguration.RunAsLocalSystem();
                hostConfiguration.SetDescription("EasyNetQ.Scheduler");
                hostConfiguration.SetDisplayName("EasyNetQ.Scheduler");
                hostConfiguration.SetServiceName("EasyNetQ.Scheduler");

                hostConfiguration.Service <ISchedulerService>(serviceConfiguration =>
                {
                    serviceConfiguration.SetServiceName("SchedulerService");
                    serviceConfiguration.ConstructUsing(_ => SchedulerServiceFactory.CreateScheduler());

                    serviceConfiguration.WhenStarted(service => service.Start());
                    serviceConfiguration.WhenStopped(service => service.Stop());
                });
            });
        }