Beispiel #1
0
        static void Main(string[] arguments)
        {
            var runPath = AppDomain.CurrentDomain.BaseDirectory;

            using (SerilogSupport.InitLogger(new Uri(string.Concat(runPath, "serilog.config"))))
            {
                AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
                    var ex = args.ExceptionObject as Exception;
                    Logging.Log().Error(ex, "Unhandled exception: {ExceptionObject} (isTerminating: {IsTerminating})", args.ExceptionObject, args.IsTerminating);
                };
                Logging.Log().Information("Version: {ApplicationVersion}", typeof(Program).Assembly.GetName().Version);
                var assemblyLocation = typeof(Program).Assembly.Location;

                if (assemblyLocation != null)
                {
                    var productVersion = FileVersionInfo.GetVersionInfo(assemblyLocation).ProductVersion;
                    Logging.Log().Information("Product Version: {ApplicationVersion}", typeof(Program).Assembly.GetName().Version);
                }

                var       environment = EnvironmentResolver.GetEnvironmentName();
                IAppCache cache       = new CachingService {
                    DefaultCacheDuration = 60 * 5
                };
                IConfigReader        configReader = ConfigReaderFactory.Create(cache, environment, "API");
                IWebApiConfiguration webApiConfig = new WebApiConfig(configReader);

                Host.Run(() => new ServiceApp(webApiConfig));

                Logging.Log().Information("Application terminated.");
            }
        }
Beispiel #2
0
        public void Start()
        {
            this.RegisterDependencies();

            new TaskFactory().StartNew(() =>
            {
                var runPath = AppDomain.CurrentDomain.BaseDirectory;
                using (SerilogSupport.InitLogger(new Uri(string.Concat(runPath, "serilog.config"))))
                {
                    AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
                    {
                        var ex = args.ExceptionObject as Exception;
                        Logging.Log().Error(ex, "Unhandled exception: {ExceptionObject} (isTerminating: {IsTerminating})", args.ExceptionObject, args.IsTerminating);
                    };
                    Logging.Log().Information("Version: {ApplicationVersion}", typeof(Program).Assembly.GetName().Version);

                    var assemblyLocation = typeof(Program).Assembly.Location;

                    if (assemblyLocation != null)
                    {
                        var productVersion = FileVersionInfo.GetVersionInfo(assemblyLocation).ProductVersion;
                        Logging.Log().Information("Product Version: {ApplicationVersion}", typeof(Program).Assembly.GetName().Version);
                    }

                    RegisterDependencies();
                    Logging.Log().Information("Hello from Sync Worker!");


                    try
                    {
                        var service = new WorkerService(container.Resolve <ISyncQueue>(), container.Resolve <SyncHandler>());
                        service.Start();
                    }
                    catch (Exception ex)
                    {
                        Logging.Log().Error(ex, "Critical exception occured. Application will close.");
                    }

                    Logging.Log().Information("Application terminated.");
                }
            });
        }