File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,11 @@ public static class ConfigurationExtensions
77{
88 public static WebApplicationBuilder RegisterCommonOpenShockOptions ( this WebApplicationBuilder builder )
99 {
10- #if DEBUG
11- Console . WriteLine ( builder . Configuration . GetDebugView ( ) ) ;
12- #endif
10+ if ( builder . Environment . IsDevelopment ( ) )
11+ {
12+ Console . WriteLine ( builder . Configuration . GetDebugView ( ) ) ;
13+ }
14+
1315 builder . Services . Configure < DatabaseOptions > ( builder . Configuration . GetRequiredSection ( DatabaseOptions . SectionName ) ) ;
1416 builder . Services . AddSingleton < IValidateOptions < DatabaseOptions > , DatabaseOptionsValidator > ( ) ;
1517
Original file line number Diff line number Diff line change 22using Hangfire . PostgreSql ;
33using OpenShock . Common ;
44using OpenShock . Common . Extensions ;
5+ using OpenShock . Cron ;
56using OpenShock . Cron . Utils ;
67
78var builder = OpenShockApplication . CreateDefaultBuilder < Program > ( args ) ;
2223
2324app . UseCommonOpenShockMiddleware ( ) ;
2425
25- app . UseHangfireDashboard ( options : new DashboardOptions
26+ var hangfireOptions = new DashboardOptions ( ) ;
27+ if ( app . Environment . IsProduction ( ) )
2628{
27- #if ! DEBUG
28- AsyncAuthorization =
29- [
30- new DashboardAdminAuth ( )
31- ]
32- #endif
33- } ) ;
29+ hangfireOptions . AsyncAuthorization = [ new DashboardAdminAuth ( ) ] ;
30+ }
31+
32+ app . UseHangfireDashboard ( options : hangfireOptions ) ;
3433
3534var jobManager = app . Services . GetRequiredService < IRecurringJobManagerV2 > ( ) ;
3635foreach ( var cronJob in CronJobCollector . GetAllCronJobs ( ) )
You can’t perform that action at this time.
0 commit comments