BuildAndDeploy

This commit is contained in:
pavelbannov 2021-09-23 20:58:39 +03:00
parent 4a0c6a94c6
commit 315665e87a
31 changed files with 112 additions and 96 deletions

View File

@ -0,0 +1,12 @@
@echo off
PUSHD %~dp0..
setlocal EnableDelayedExpansion
call build\build.backend.bat
if %errorlevel% == 0 (
for /R "build\run\" %%f in (*.bat) do (
call build\run\%%~nxf publish
call dotnet -d publish -c Debug --no-restore --no-build --self-contained -o !servicepath! !servicesource!!servicename!.csproj
)
)

View File

@ -14,14 +14,7 @@ echo "FRONT-END static"
call build\build.static.bat
echo "BACK-END"
call build\build.backend.bat
if %errorlevel% == 0 (
for /R "build\run\" %%f in (*.bat) do (
call build\run\%%~nxf publish
call dotnet -d publish -c Debug --no-restore --no-build --self-contained -o !servicepath! !servicesource!!servicename!.csproj
)
)
call build\buildAndDeploy.backend.bat
rem start /b call build\start\start.bat

View File

@ -1,9 +1,12 @@
PUSHD %~dp0..
call runasadmin.bat "%~dpnx0"
PUSHD %~dp0..\..
setlocal EnableDelayedExpansion
if %errorlevel% == 0 (
for /R "run\" %%f in (*.bat) do (
call run\%%~nxf service
call sc install "Onlyoffice %%~nf" binPath="%servicepath%"
for /R "build\run\" %%f in (*.bat) do (
call build\run\%%~nxf service
echo !servicepath!
call sc create "Onlyoffice %%~nf" binPath="!servicepath!"
)
)
pause

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\apisystem
set servicepath=%cd%\deploy\services\apisystem\
set servicename=ASC.ApiSystem
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.ApiSystem\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=apisystem
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5010 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=apisystem pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\backup
set servicepath=%cd%\deploy\services\backup\
set servicename=ASC.Data.Backup
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Data.Backup\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=backup
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5012 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=backup pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\products\ASC.Calendar\server
set servicepath=%cd%\deploy\products\ASC.Calendar\server\
set servicename=ASC.Calendar
PUSHD %~dp0..\..
set servicesource=%cd%\products\ASC.Calendar\Server\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=calendar
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5023 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=calendar pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\clearevents
set servicepath=%cd%\deploy\services\clearevents\
set servicename=ASC.ClearEvents
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.ClearEvents\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=clearEvents
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5027 $STORAGE_ROOT=..\..\..\..\Data --log__dir=..\..\..\..\Logs --log__name=clearEvents pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -7,7 +7,7 @@ PUSHD %~dp0..\..
set servicesource=%cd%\products\ASC.CRM\Server\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=crm
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5021 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=crm pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\encryption
set servicepath=%cd%\deploy\services\encryption\
set servicename=ASC.Data.Storage.Encryption
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Data.Storage.Encryption\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=encryption
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5019 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=encryption pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -7,7 +7,7 @@ PUSHD %~dp0..\..
set servicesource=%cd%\products\ASC.Files\Server\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=files
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5007 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=files pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -7,7 +7,7 @@ PUSHD %~dp0..\..
set servicesource=%cd%\products\ASC.Files\Service\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=files.service
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5009 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=files.service pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\products\ASC.Mail\server
set servicepath=%cd%\deploy\products\ASC.Mail\server\
set servicename=ASC.Mail
PUSHD %~dp0..\..
set servicesource=%cd%\products\ASC.Mail\Server\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=mail
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5022 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=mail pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\migration
set servicepath=%cd%\deploy\services\migration\
set servicename=ASC.Data.Storage.Migration
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Data.Storage.Migration\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=migration
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5018 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=migration pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\notify
set servicepath=%cd%\deploy\services\notify\
set servicename=ASC.Notify
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Notify\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=notify
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5005 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=notify pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -7,7 +7,7 @@ PUSHD %~dp0..\..
set servicesource=%cd%\products\ASC.People\Server\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=people
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5004 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=people pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\products\ASC.Projects\server
set servicepath=%cd%\deploy\products\ASC.Projects\server\
set servicename=ASC.Projects
PUSHD %~dp0..\..
set servicesource=%cd%\products\ASC.Projects\Server\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=projects
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5020 $STORAGE_ROOT=..\..\..\..\..\Data log__dir=..\..\..\..\..\Logs log:name=projects pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\radicale\service
set servicepath=%cd%\deploy\services\radicale\service\
set servicename=ASC.Radicale
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Radicale\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=radicale
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5024 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log__name=radicale pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\socket\service
set servicepath=%cd%\deploy\services\socket\service\
set servicename=ASC.Socket.IO.Svc
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Socket.IO.Svc\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=socket
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5028 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=socket pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\ssoauth\service
set servicepath=%cd%\deploy\services\ssoauth\service\
set servicename=ASC.SsoAuth.Svc
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.SsoAuth.Svc\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=ssoauth
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5031 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=ssoauth pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\studio.notify
set servicepath=%cd%\deploy\services\studio.notify\
set servicename=ASC.Studio.Notify
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Studio.Notify\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=studio.notify
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5006 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=studio.notify pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\telegram
set servicepath=%cd%\deploy\services\telegram\
set servicename=ASC.TelegramService
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.TelegramService\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=telegram
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:51702 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=telegram pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\services\thumb\service
set servicepath=%cd%\deploy\services\thumb\service\
set servicename=ASC.Thumbnails.Svc
PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.Thumbnails.Svc\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=thumbnails
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5030 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs --log__name=thumbnails pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -7,7 +7,7 @@ PUSHD %~dp0..\..
set servicesource=%cd%\common\services\ASC.UrlShortener.Svc\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\..\Data --log__dir=..\..\..\Logs --log__name=urlshortener
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5029 $STORAGE_ROOT=..\..\..\..\..\Data log:dir=..\..\..\..\..\Logs log:name=urlshortener pathToConf=..\..\..\..\..\config core:products:folder=..\..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -1,13 +1,13 @@
@echo off
PUSHD %~dp0..
set servicepath=%cd%\deploy\studio\api
set servicepath=%cd%\deploy\studio\api\
set servicename=ASC.Web.Api
PUSHD %~dp0..\..
set servicesource=%cd%\web\ASC.Web.Api\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=api
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5000 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=api pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -7,7 +7,7 @@ PUSHD %~dp0..\..
set servicesource=%cd%\web\ASC.Web.Studio\
if "%1%" == "service" (
set servicepath=%servicepath%%servicename%.exe --$STORAGE_ROOT=..\..\Data --log__dir=..\..\Logs --log__name=studio
set servicepath=%servicepath%%servicename%.exe urls=http://0.0.0.0:5003 $STORAGE_ROOT=..\..\..\..\Data log:dir=..\..\..\..\Logs log:name=studio pathToConf=..\..\..\..\config core:products:folder=..\..\products core:products:subfolder=server
) else (
if NOT "%1%" == "publish" (
call %servicepath%%servicename%.exe

View File

@ -177,7 +177,7 @@ namespace ASC.Api.Core
{
return hostBuilder.ConfigureLogging((hostBuildexContext, r) =>
{
_ = new ConfigureLogNLog(hostBuildexContext.Configuration, new ConfigurationExtension(hostBuildexContext.Configuration));
_ = new ConfigureLogNLog(hostBuildexContext.Configuration, new ConfigurationExtension(hostBuildexContext.Configuration), hostBuildexContext.HostingEnvironment);
r.AddNLog(LogManager.Configuration);
});
}

View File

@ -43,6 +43,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<!-- <PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="2.9.4">

View File

@ -35,6 +35,7 @@ using log4net.Config;
using log4net.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using NLog;
@ -385,11 +386,12 @@ namespace ASC.Common.Logging
private IConfiguration Configuration { get; }
private ConfigurationExtension ConfigurationExtension { get; }
public ConfigureLogNLog(IConfiguration configuration, ConfigurationExtension configurationExtension)
public ConfigureLogNLog(IConfiguration configuration, ConfigurationExtension configurationExtension, IHostEnvironment hostingEnvironment)
{
Configuration = configuration;
ConfigurationExtension = configurationExtension;
LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(CrossPlatform.PathCombine(Configuration["pathToConf"], "nlog.config"));
LogManager.ThrowConfigExceptions = false;
@ -401,14 +403,14 @@ namespace ASC.Common.Logging
if (!string.IsNullOrEmpty(settings.Dir))
{
LogManager.Configuration.Variables["dir"] = settings.Dir.TrimEnd('/').TrimEnd('\\') + Path.DirectorySeparatorChar;
LogManager.Configuration.Variables["dir"] = CrossPlatform.PathCombine(hostingEnvironment.ContentRootPath, settings.Dir).TrimEnd('/').TrimEnd('\\') + Path.DirectorySeparatorChar;
}
NLog.Targets.Target.Register<SelfCleaningTarget>("SelfCleaning");
}
public void Configure(LogNLog options)
{
{
options.Configure("ASC");
}

View File

@ -24,10 +24,8 @@
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using ASC.Api.Core;
@ -55,29 +53,7 @@ namespace ASC.ApiSystem
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
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);
}
}
});
})
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>())
.ConfigureAppConfiguration((hostingContext, config) =>
{
var buided = config.Build();

View File

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common.Utils;
using Autofac.Extensions.DependencyInjection;
@ -23,10 +26,36 @@ namespace ASC.Calendar
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
var builder = webBuilder.UseStartup<Startup>();
builder.ConfigureKestrel((hostingContext, serverOptions) =>
{
serverOptions.Limits.MaxRequestBodySize = 100 * 1024 * 1024;
serverOptions.Limits.MaxRequestBufferSize = 100 * 1024 * 1024;
serverOptions.Limits.MinRequestBodyDataRate = null;
serverOptions.Limits.MinResponseDataRate = null;
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);
}
}
});
})
.ConfigureAppConfiguration((hostingContext, config) =>
{
@ -34,22 +63,22 @@ namespace ASC.Calendar
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(Path.Combine(hostingContext.HostingEnvironment.ContentRootPath, path));
path = Path.GetFullPath(CrossPlatform.PathCombine(hostingContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
config
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path}
})
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args);
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path}
});
})
.ConfigureNLogLogging();
}

View File

@ -48,11 +48,6 @@ namespace ASC.Files.Service
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
)
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"appsettings.services.json", true)
@ -63,7 +58,12 @@ namespace ASC.Files.Service
.AddJsonFile($"kafka.{env}.json", true)
.AddJsonFile("elastic.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args);
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
);
})
.ConfigureServices((hostContext, services) =>
{