DocSpace-buildtools/common/services/ASC.Studio.Notify/Program.cs

70 lines
2.6 KiB
C#
Raw Normal View History

2019-11-15 08:47:56 +00:00
using System.Collections.Generic;
using System.IO;
2019-08-01 08:47:15 +00:00
using System.Threading.Tasks;
2019-12-20 11:17:01 +00:00
2020-02-17 08:58:14 +00:00
using ASC.Common;
2019-08-01 08:47:15 +00:00
using ASC.Common.DependencyInjection;
using ASC.Common.Logging;
2019-08-01 08:47:15 +00:00
using ASC.Notify;
2019-12-20 11:17:01 +00:00
2019-08-01 08:47:15 +00:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace ASC.Studio.Notify
{
public class Program
{
public static async Task Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(Path.Combine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
2019-09-25 12:55:35 +00:00
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
2019-08-01 08:47:15 +00:00
config
2019-11-15 08:47:56 +00:00
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
)
2019-08-01 08:47:15 +00:00
.AddJsonFile("appsettings.json")
2019-09-25 12:49:21 +00:00
.AddJsonFile($"appsettings.{env}.json", true)
2019-08-01 08:47:15 +00:00
.AddJsonFile($"appsettings.services.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("notify.json")
2019-08-23 12:49:23 +00:00
.AddJsonFile("kafka.json")
2019-11-14 09:21:15 +00:00
.AddJsonFile($"kafka.{env}.json", true)
2020-06-04 13:26:31 +00:00
.AddEnvironmentVariables()
.AddCommandLine(args);
2019-08-01 08:47:15 +00:00
})
.ConfigureServices((hostContext, services) =>
{
2020-02-17 08:58:14 +00:00
var diHelper = new DIHelper(services);
diHelper.AddNLogManager("ASC.Notify", "ASC.Notify.Messages");
2019-08-01 08:47:15 +00:00
services.AddHostedService<ServiceLauncher>();
2020-02-17 08:58:14 +00:00
diHelper.AddServiceLauncher();
2019-12-20 11:17:01 +00:00
2020-06-04 13:46:58 +00:00
services.AddAutofac(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
2019-08-01 08:47:15 +00:00
})
.UseConsoleLifetime()
.Build();
using (host)
{
// Start the host
await host.StartAsync();
// Wait for the host to shutdown
await host.WaitForShutdownAsync();
}
}
}
}