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=DumbYT;User Id=DumbYT;Password=DumbYTPassword;"; 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(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.UseCors(b => { b.AllowAnyOrigin(); b.AllowAnyMethod(); }); app.UseMvc(); app.UseHangfireServer(); app.UseHangfireDashboard(); } } }