DocSpace-buildtools/common/services/ASC.Data.Backup/Program.cs

51 lines
1.8 KiB
C#
Raw Normal View History

2020-07-03 15:57:59 +00:00
using System.Collections.Generic;
2020-06-08 08:17:54 +00:00
using System.IO;
2020-07-03 15:57:59 +00:00
using System.Threading.Tasks;
2020-06-23 10:48:36 +00:00
using Microsoft.AspNetCore.Hosting;
2020-06-03 09:15:05 +00:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
namespace ASC.Data.Backup
{
public class Program
{
public static async Task Main(string[] args)
{
2020-07-16 13:02:21 +00:00
Host.CreateDefaultBuilder(args)
2020-06-23 10:48:36 +00:00
.ConfigureWebHostDefaults(webBuilder =>
{
2020-09-30 11:50:39 +00:00
_ = webBuilder.UseStartup<Startup>();
2020-06-23 10:48:36 +00:00
})
2020-06-03 09:15:05 +00:00
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(Path.Combine(hostContext.HostingEnvironment.ContentRootPath, path));
}
2020-09-30 11:50:39 +00:00
_ = config.SetBasePath(path);
2020-06-03 09:15:05 +00:00
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
2020-09-30 11:50:39 +00:00
_ = config
2020-06-03 09:15:05 +00:00
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("notify.json")
.AddJsonFile("backup.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddEnvironmentVariables();
})
.UseConsoleLifetime()
2020-07-16 13:02:21 +00:00
.Build()
.Run();
2020-06-03 09:15:05 +00:00
}
}
}