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

56 lines
2.0 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;
using ASC.Common.Utils;
2020-11-02 16:27:08 +00:00
using Autofac.Extensions.DependencyInjection;
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-11-02 16:27:08 +00:00
await Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
2020-06-23 10:48:36 +00:00
.ConfigureWebHostDefaults(webBuilder =>
{
2020-10-12 19:39:23 +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(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
2020-06-03 09:15:05 +00:00
}
2020-10-12 19:39:23 +00:00
config.SetBasePath(path);
2020-06-03 09:15:05 +00:00
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
2020-10-12 19:39:23 +00:00
config
2020-06-03 09:15:05 +00:00
.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)
2020-11-26 17:30:57 +00:00
.AddEnvironmentVariables()
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
);
2020-06-03 09:15:05 +00:00
})
.UseConsoleLifetime()
2020-07-16 13:02:21 +00:00
.Build()
2020-10-12 13:52:31 +00:00
.RunAsync();
2020-06-03 09:15:05 +00:00
}
}
}