47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Hangfire;
|
|
using Hangfire.PostgreSql;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace YTManager {
|
|
public class Startup {
|
|
public Startup(IConfiguration configuration) {
|
|
Configuration = configuration;
|
|
}
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
public static string DBStr {
|
|
get {
|
|
string s = Environment.GetEnvironmentVariable("POSTGRESQL_DBSTR");
|
|
s = s ?? "Server=localhost;Port=32768;Database=postgres;User Id=postgres;";
|
|
return s;
|
|
}
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
public void ConfigureServices(IServiceCollection services) {
|
|
Console.WriteLine("Using db string of: " + DBStr);
|
|
services.AddMvc();
|
|
services.AddDbContext<MediaDB>(x => x.UseNpgsql(DBStr));
|
|
services.AddHangfire(x => x.UsePostgreSqlStorage(DBStr));
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
|
|
if (env.IsDevelopment())
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
app.UseDefaultFiles();
|
|
app.UseStaticFiles();
|
|
app.UseMvc();
|
|
app.UseHangfireServer();
|
|
app.UseHangfireDashboard();
|
|
}
|
|
}
|
|
}
|