Skip to content

Commit 007a1b9

Browse files
committed
move hangfire into its own pod
1 parent fe2b002 commit 007a1b9

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

RelistenApi/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
4040
{
4141
o.Dsn = sentryDsn;
4242
o.SendDefaultPii = true; // we don't have PII?
43+
o.Debug = true;
4344
});
4445
}
4546
});

RelistenApi/Startup.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ public void ConfigureServices(IServiceCollection services)
9090
var action = descriptor.ActionName;
9191

9292
var pathParameters = descriptor.Parameters
93-
.Where(p => p.BindingInfo is null || p.BindingInfo.BindingSource?.Id == "Path")
93+
.Where(p => p.BindingInfo is null ||
94+
p.BindingInfo.BindingSource?.Id == "Path")
9495
.Select(p => $"{{{p.Name}}}");
9596

9697
var route = string.Join("/", [controller, action, .. pathParameters]);
@@ -228,20 +229,25 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
228229

229230
if (!env.IsDevelopment())
230231
{
231-
app.UseHangfireServer(new BackgroundJobServerOptions
232+
if (!string.IsNullOrEmpty(Configuration["ENABLE_HANGFIRE_SERVER"]) &&
233+
Configuration["ENABLE_HANGFIRE_SERVER"] != "false")
232234
{
233-
Queues = new[] { "artist_import" },
234-
ServerName = $"relistenapi:artist_import ({Environment.MachineName})",
235-
WorkerCount = 1
236-
});
235+
app.UseHangfireServer(new BackgroundJobServerOptions
236+
{
237+
Queues = ["artist_import"],
238+
ServerName = $"relistenapi:artist_import ({Environment.MachineName})",
239+
WorkerCount = 3
240+
});
237241

238-
app.UseHangfireServer(new BackgroundJobServerOptions
239-
{
240-
Queues = new[] { "default" }, ServerName = $"relistenapi:default ({Environment.MachineName})"
241-
});
242+
app.UseHangfireServer(new BackgroundJobServerOptions
243+
{
244+
Queues = ["default"],
245+
ServerName = $"relistenapi:default ({Environment.MachineName})"
246+
});
247+
}
242248

243249
app.UseHangfireDashboard("/relisten-admin/hangfire",
244-
new DashboardOptions { Authorization = new[] { new MyAuthorizationFilter() } });
250+
new DashboardOptions { Authorization = [new MyAuthorizationFilter()] });
245251
}
246252

247253
app.UseSwagger(c =>

0 commit comments

Comments
 (0)