2017-09-01 08:55:02 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Hangfire;
|
2018-02-20 04:57:14 +00:00
|
|
|
|
using Hangfire.PostgreSql;
|
2017-09-01 08:55:02 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace YTManager {
|
2017-09-03 07:00:16 +00:00
|
|
|
|
public class Startup {
|
|
|
|
|
public Startup(IConfiguration configuration) {
|
2017-09-01 08:55:02 +00:00
|
|
|
|
Configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
|
|
2018-02-20 04:57:14 +00:00
|
|
|
|
public static string DBStr {
|
|
|
|
|
get {
|
|
|
|
|
string s = Environment.GetEnvironmentVariable("POSTGRESQL_DBSTR");
|
|
|
|
|
s = s ?? "Server=localhost;Port=32768;Database=postgres;User Id=postgres;";
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-03 07:00:16 +00:00
|
|
|
|
|
2017-09-01 08:55:02 +00:00
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
2017-09-03 07:00:16 +00:00
|
|
|
|
public void ConfigureServices(IServiceCollection services) {
|
2018-02-20 04:57:14 +00:00
|
|
|
|
Console.WriteLine("Using db string of: " + DBStr);
|
2017-09-01 08:55:02 +00:00
|
|
|
|
services.AddMvc();
|
2018-02-20 04:57:14 +00:00
|
|
|
|
services.AddDbContext<MediaDB>(x => x.UseNpgsql(DBStr));
|
|
|
|
|
services.AddHangfire(x => x.UsePostgreSqlStorage(DBStr));
|
2017-09-01 08:55:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
2017-09-03 07:00:16 +00:00
|
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
|
2017-09-01 08:55:02 +00:00
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
|
|
|
|
|
app.UseDefaultFiles();
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
app.UseMvc();
|
|
|
|
|
app.UseHangfireServer();
|
|
|
|
|
app.UseHangfireDashboard();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|