From b1da136f77e5436cf1f80594e68369f322d6579f Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 9 Apr 2018 14:31:39 +0900 Subject: [PATCH] Update packages and remove hangfire hack --- BTCPayServer.Tests/docker-compose.yml | 6 +- BTCPayServer/BTCPayServer.csproj | 6 +- .../Configuration/BTCPayServerOptions.cs | 3 +- BTCPayServer/Hosting/Startup.cs | 60 ++++++------------- 4 files changed, 26 insertions(+), 49 deletions(-) diff --git a/BTCPayServer.Tests/docker-compose.yml b/BTCPayServer.Tests/docker-compose.yml index d95b8c83a..f7f6a9961 100644 --- a/BTCPayServer.Tests/docker-compose.yml +++ b/BTCPayServer.Tests/docker-compose.yml @@ -46,7 +46,7 @@ services: - lightning-charged nbxplorer: - image: nicolasdorier/nbxplorer:1.0.1.25 + image: nicolasdorier/nbxplorer:1.0.1.26 ports: - "32838:32838" expose: @@ -89,7 +89,7 @@ services: - "bitcoin_datadir:/data" customer_lightningd: - image: nicolasdorier/clightning:0.0.0.2 + image: nicolasdorier/clightning:0.0.0.3 environment: EXPOSE_TCP: "true" LIGHTNINGD_OPT: | @@ -129,7 +129,7 @@ services: - merchant_lightningd merchant_lightningd: - image: nicolasdorier/clightning:0.0.0.2 + image: nicolasdorier/clightning:0.0.0.3 environment: EXPOSE_TCP: "true" LIGHTNINGD_OPT: | diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index a0beddb13..37714320b 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -31,7 +31,7 @@ - + @@ -39,10 +39,10 @@ - + - + diff --git a/BTCPayServer/Configuration/BTCPayServerOptions.cs b/BTCPayServer/Configuration/BTCPayServerOptions.cs index 25f5b55b1..3e15e875e 100644 --- a/BTCPayServer/Configuration/BTCPayServerOptions.cs +++ b/BTCPayServer/Configuration/BTCPayServerOptions.cs @@ -94,7 +94,8 @@ namespace BTCPayServer.Configuration ExternalUrl = conf.GetOrDefault("externalurl", null); RootPath = conf.GetOrDefault("rootpath", "/"); - + if (!RootPath.StartsWith("/", StringComparison.InvariantCultureIgnoreCase)) + RootPath = "/" + RootPath; var old = conf.GetOrDefault("internallightningnode", null); if(old != null) throw new ConfigException($"internallightningnode should not be used anymore, use btclightning instead"); diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index fe3792f5b..8d5627680 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -76,8 +76,6 @@ namespace BTCPayServer.Hosting .AddEntityFrameworkStores() .AddDefaultTokenProviders(); - // Big hack, tests fails because Hangfire fail at initializing at the second test run - AddHangfireFix(services); services.AddBTCPayServer(); services.AddMvc(o => { @@ -93,6 +91,24 @@ namespace BTCPayServer.Hosting options.Password.RequireUppercase = false; }); + services.AddHangfire((o) => + { + var scope = AspNetCoreJobActivator.Current.BeginScope(null); + var options = (ApplicationDbContextFactory)scope.Resolve(typeof(ApplicationDbContextFactory)); + options.ConfigureHangfireBuilder(o); + }); + services.AddCors(o => + { + o.AddPolicy("BitpayAPI", b => + { + b.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); + }); + }); + services.Configure>(o => + { + o.Value.DeveloperMode = _Env.IsDevelopment(); + }); + // Needed to debug U2F for ledger support //services.Configure(kestrel => //{ @@ -103,46 +119,6 @@ namespace BTCPayServer.Hosting //}); } - // Big hack, tests fails if only call AddHangfire because Hangfire fail at initializing at the second test run - private void AddHangfireFix(IServiceCollection services) - { - Action configuration = o => - { - var scope = AspNetCoreJobActivator.Current.BeginScope(null); - var options = (ApplicationDbContextFactory)scope.Resolve(typeof(ApplicationDbContextFactory)); - options.ConfigureHangfireBuilder(o); - }; - - ServiceCollectionDescriptorExtensions.TryAddSingleton>(services, (IServiceProvider serviceProvider) => new Action((config) => - { - ILoggerFactory service = ServiceProviderServiceExtensions.GetService(serviceProvider); - if (service != null) - { - Hangfire.GlobalConfigurationExtensions.UseLogProvider(config, new AspNetCoreLogProvider(service)); - } - IServiceScopeFactory service2 = ServiceProviderServiceExtensions.GetService(serviceProvider); - if (service2 != null) - { - Hangfire.GlobalConfigurationExtensions.UseActivator(config, new AspNetCoreJobActivator(service2)); - } - configuration(config); - })); - - services.AddHangfire(configuration); - services.AddCors(o => - { - o.AddPolicy("BitpayAPI", b => - { - b.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); - }); - }); - - services.Configure>(o => - { - o.Value.DeveloperMode = _Env.IsDevelopment(); - }); - } - public void Configure( IApplicationBuilder app, IHostingEnvironment env,