2020-02-25 08:45:16 +00:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* (c) Copyright Ascensio System Limited 2010-2018
|
|
|
|
|
*
|
|
|
|
|
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
|
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
|
|
|
|
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
|
|
|
|
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
|
|
|
|
*
|
|
|
|
|
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
|
|
|
|
*
|
|
|
|
|
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
|
|
|
|
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
|
|
|
|
*
|
|
|
|
|
* Pursuant to Section 7 <EFBFBD> 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
|
|
|
|
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
|
|
|
|
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
|
|
|
|
* in every copy of the program you distribute.
|
|
|
|
|
* Pursuant to Section 7 <EFBFBD> 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-18 13:48:38 +00:00
|
|
|
|
namespace ASC.ApiSystem
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
2021-04-23 13:54:12 +00:00
|
|
|
|
public async static Task Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var host = CreateHostBuilder(args).Build();
|
|
|
|
|
await host.RunAsync();
|
2020-02-18 13:48:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 17:58:39 +00:00
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
2021-04-23 13:54:12 +00:00
|
|
|
|
Host.CreateDefaultBuilder(args)
|
|
|
|
|
.UseSystemd()
|
2021-11-25 13:48:08 +00:00
|
|
|
|
.UseWindowsService()
|
2020-11-02 16:27:08 +00:00
|
|
|
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
2020-09-30 14:47:42 +00:00
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
{
|
2021-04-23 13:54:12 +00:00
|
|
|
|
var builder = webBuilder.UseStartup<Startup>();
|
|
|
|
|
|
|
|
|
|
builder.ConfigureKestrel((hostingContext, serverOptions) =>
|
|
|
|
|
{
|
|
|
|
|
var kestrelConfig = hostingContext.Configuration.GetSection("Kestrel");
|
|
|
|
|
|
|
|
|
|
if (!kestrelConfig.Exists()) return;
|
|
|
|
|
|
|
|
|
|
var unixSocket = kestrelConfig.GetValue<string>("ListenUnixSocket");
|
|
|
|
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
|
{
|
|
|
|
|
if (!String.IsNullOrWhiteSpace(unixSocket))
|
|
|
|
|
{
|
|
|
|
|
unixSocket = String.Format(unixSocket, hostingContext.HostingEnvironment.ApplicationName.Replace("ASC.", "").Replace(".", ""));
|
|
|
|
|
|
|
|
|
|
serverOptions.ListenUnixSocket(unixSocket);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-09-30 14:47:42 +00:00
|
|
|
|
})
|
|
|
|
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
|
|
|
|
{
|
2020-10-12 16:23:15 +00:00
|
|
|
|
var buided = config.Build();
|
|
|
|
|
var path = buided["pathToConf"];
|
|
|
|
|
if (!Path.IsPathRooted(path))
|
|
|
|
|
{
|
2021-04-16 13:26:26 +00:00
|
|
|
|
path = Path.GetFullPath(CrossPlatform.PathCombine(hostingContext.HostingEnvironment.ContentRootPath, path));
|
2020-10-12 16:23:15 +00:00
|
|
|
|
}
|
2020-09-30 14:47:42 +00:00
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
config.SetBasePath(path);
|
|
|
|
|
config
|
2020-10-12 16:23:15 +00:00
|
|
|
|
.AddJsonFile("appsettings.json")
|
|
|
|
|
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
|
|
|
|
|
.AddJsonFile("storage.json")
|
|
|
|
|
.AddJsonFile("kafka.json")
|
|
|
|
|
.AddJsonFile($"kafka.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
|
2021-12-21 16:16:34 +00:00
|
|
|
|
.AddJsonFile("redis.json")
|
|
|
|
|
.AddJsonFile($"redis.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
|
2020-10-12 16:23:15 +00:00
|
|
|
|
.AddEnvironmentVariables()
|
2020-11-26 17:30:57 +00:00
|
|
|
|
.AddCommandLine(args)
|
|
|
|
|
.AddInMemoryCollection(new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{"pathToConf", path}
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-08 13:19:54 +00:00
|
|
|
|
})
|
|
|
|
|
.ConfigureNLogLogging();
|
2020-02-18 13:48:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|