delete svc projects

This commit is contained in:
Anton Suhorukov 2022-03-01 15:54:23 +03:00
parent 34fc3e545d
commit 61a127413c
14 changed files with 0 additions and 851 deletions

View File

@ -58,8 +58,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Thumbnails.Svc", "commo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Files.Core", "products\ASC.Files\Core\ASC.Files.Core.csproj", "{F0A39728-940D-4DBE-A37A-05D4EB57F342}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Socket.IO.Svc", "common\services\ASC.Socket.IO.Svc\ASC.Socket.IO.Svc.csproj", "{2DADEAD3-0FE9-4199-9817-41A32E6BF450}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Storage.Migration", "common\services\ASC.Data.Storage.Migration\ASC.Data.Storage.Migration.csproj", "{02356BD7-7E99-457B-BEFF-090CE4DF067D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Data.Storage.Encryption", "common\services\ASC.Data.Storage.Encryption\ASC.Data.Storage.Encryption.csproj", "{17A05AE2-21C8-4C1C-B422-6AB80F13F63E}"
@ -83,8 +81,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Mail", "products\ASC.Ma
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Radicale", "common\services\ASC.Radicale\ASC.Radicale.csproj", "{74998718-3C9A-4A89-B834-14453762C60F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.SsoAuth.Svc", "common\services\ASC.SsoAuth.Svc\ASC.SsoAuth.Svc.csproj", "{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.Web.HealthChecks.UI", "web\ASC.Web.HealthChecks.UI\ASC.Web.HealthChecks.UI.csproj", "{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASC.ClearEvents", "common\services\ASC.ClearEvents\ASC.ClearEvents.csproj", "{448221A8-EABA-4200-9192-E08BF241A487}"
@ -209,10 +205,6 @@ Global
{F0A39728-940D-4DBE-A37A-05D4EB57F342}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0A39728-940D-4DBE-A37A-05D4EB57F342}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0A39728-940D-4DBE-A37A-05D4EB57F342}.Release|Any CPU.Build.0 = Release|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DADEAD3-0FE9-4199-9817-41A32E6BF450}.Release|Any CPU.Build.0 = Release|Any CPU
{02356BD7-7E99-457B-BEFF-090CE4DF067D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02356BD7-7E99-457B-BEFF-090CE4DF067D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02356BD7-7E99-457B-BEFF-090CE4DF067D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -249,10 +241,6 @@ Global
{74998718-3C9A-4A89-B834-14453762C60F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74998718-3C9A-4A89-B834-14453762C60F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74998718-3C9A-4A89-B834-14453762C60F}.Release|Any CPU.Build.0 = Release|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AD828EA-FBA2-4D30-B969-756B3BE78E4E}.Release|Any CPU.Build.0 = Release|Any CPU
{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C1A387E-0CD0-4BE8-82FC-9FCAD05BF289}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -22,7 +22,6 @@
"common\\services\\ASC.ElasticSearch\\ASC.ElasticSearch.csproj",
"common\\services\\ASC.Feed.Aggregator\\ASC.Feed.Aggregator.csproj",
"common\\services\\ASC.Notify\\ASC.Notify.csproj",
"common\\services\\ASC.Socket.IO.Svc\\ASC.Socket.IO.Svc.csproj",
"common\\services\\ASC.Studio.Notify\\ASC.Studio.Notify.csproj",
"common\\services\\ASC.TelegramService\\ASC.TelegramService.csproj",
"common\\services\\ASC.Webhooks.Service\\ASC.Webhooks.Service.csproj",

View File

@ -1,36 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="7.2.1" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="7.2.1" />
<PackageReference Include="SocketIOClient" Version="3.0.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ASC.Api.Core\ASC.Api.Core.csproj" />
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\..\ASC.Core.Common\ASC.Core.Common.csproj" />
<ProjectReference Include="..\..\ASC.Data.Encryption\ASC.Data.Encryption.csproj" />
</ItemGroup>
</Project>

View File

@ -1,131 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* 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 § 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 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StackExchange.Redis.Extensions.Core.Configuration;
using StackExchange.Redis.Extensions.Newtonsoft;
namespace ASC.Socket.IO.Svc
{
public class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<BaseWorkerStartup>())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config
.AddJsonFile("appsettings.json")
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddJsonFile("redis.json")
.AddJsonFile($"redis.{env}.json", true)
.AddJsonFile("socket.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"socket.{env}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
);
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
services.AddHttpClient();
var diHelper = new DIHelper(services);
var redisConfiguration = hostContext.Configuration.GetSection("Redis").Get<RedisConfiguration>();
var kafkaConfiguration = hostContext.Configuration.GetSection("kafka").Get<KafkaSettings>();
if (kafkaConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCacheNotify<>));
}
else if (redisConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCacheNotify<>));
services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>(redisConfiguration);
}
else
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(MemoryCacheNotify<>));
}
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
services.AddHostedService<SocketServiceLauncher>();
diHelper.TryAdd<SocketServiceLauncher>();
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, false, false);
})
.ConfigureNLogLogging();
}
}

View File

@ -1,29 +0,0 @@
{
"profiles": {
"Kestrel WebServer": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "socket",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5028",
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WSL 2 : Ubuntu 20.04": {
"commandName": "WSL2",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "socket",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5028",
"ASPNETCORE_ENVIRONMENT": "Development"
},
"distributionName": "Ubuntu-20.04"
}
}
}

View File

@ -1,287 +0,0 @@
/*
*
* (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 § 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 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Utils;
using ASC.Core;
using ASC.Core.Notify.Signalr;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using SocketIOClient;
namespace ASC.Socket.IO.Svc
{
[Singletone]
public class SocketServiceLauncher : IHostedService
{
private int PingInterval { get; set; }
private int ReconnectAttempts { get; set; }
private Process Proc { get; set; }
private ProcessStartInfo StartInfo { get; set; }
private SocketIO SocketClient { get; set; }
private CancellationTokenSource CancellationTokenSource { get; set; }
private ILog Logger { get; set; }
private string LogDir { get; set; }
private IConfiguration Configuration { get; set; }
private ConfigurationExtension ConfigurationExtension { get; }
private CoreBaseSettings CoreBaseSettings { get; set; }
private SignalrServiceClient SignalrServiceClient { get; set; }
private IHostEnvironment HostEnvironment { get; set; }
public SocketServiceLauncher(
IOptionsMonitor<ILog> options,
IConfiguration configuration,
ConfigurationExtension configurationExtension,
CoreBaseSettings coreBaseSettings,
IOptionsSnapshot<SignalrServiceClient> signalrServiceClient,
IHostEnvironment hostEnvironment)
{
Logger = options.CurrentValue;
Configuration = configuration;
ConfigurationExtension = configurationExtension;
CoreBaseSettings = coreBaseSettings;
SignalrServiceClient = signalrServiceClient.Value;
HostEnvironment = hostEnvironment;
}
public Task StartAsync(CancellationToken cancellationToken)
{
try
{
var settings = ConfigurationExtension.GetSetting<SocketSettings>("socket");
var path = settings.Path;
if (!Path.IsPathRooted(settings.Path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, settings.Path));
}
PingInterval = settings.PingInterval.GetValueOrDefault(10000);
ReconnectAttempts = settings.ReconnectAttempts.GetValueOrDefault(5);
StartInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "node",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"\"{Path.Combine(path, "server.js")}\"",
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
};
StartInfo.EnvironmentVariables.Add("core.machinekey", Configuration["core:machinekey"]);
StartInfo.EnvironmentVariables.Add("port", settings.Port);
if (!string.IsNullOrEmpty(settings.RedisHost) && !string.IsNullOrEmpty(settings.RedisPort))
{
StartInfo.EnvironmentVariables.Add("redis:host", settings.RedisHost);
StartInfo.EnvironmentVariables.Add("redis:port", settings.RedisPort);
}
if (CoreBaseSettings.Standalone)
{
StartInfo.EnvironmentVariables.Add("portal.internal.url", "http://localhost");
}
LogDir = Logger.LogDirectory;
StartInfo.EnvironmentVariables.Add("logPath", CrossPlatform.PathCombine(LogDir, "socket-io.%DATE%.log"));
StartNode();
}
catch (Exception e)
{
Logger.Error(e);
}
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken cancellationToken)
{
StopPing();
StopNode();
return Task.CompletedTask;
}
private void StartNode()
{
StopNode();
Proc = Process.Start(StartInfo);
CancellationTokenSource = new CancellationTokenSource();
var task = new Task(StartPing, CancellationTokenSource.Token, TaskCreationOptions.LongRunning);
task.Start(TaskScheduler.Default);
}
private void StopNode()
{
try
{
if (Proc != null && !Proc.HasExited)
{
Proc.Kill();
if (!Proc.WaitForExit(10000)) /* wait 10 seconds */
{
Logger.Warn("The process does not wait for completion.");
}
Proc.Close();
Proc.Dispose();
Proc = null;
}
}
catch (Exception e)
{
Logger.Error("SocketIO failed stop", e);
}
}
private async void StartPing()
{
try
{
var settings = ConfigurationExtension.GetSetting<SocketSettings>("socket");
var uri = new Uri($"ws://localhost:{settings.Port}"); //TODO: replace localhost to variable
var token = SignalrServiceClient.CreateAuthToken();
SocketClient = new SocketIO(uri, new SocketIOOptions
{
ExtraHeaders = new Dictionary<string, string>
{
{ "Authorization", token }
},
ConnectionTimeout = TimeSpan.FromSeconds(30),
Reconnection = true,
ReconnectionAttempts = ReconnectAttempts,
EIO = 4,
Path = "/socket.io",
Transport = SocketIOClient.Transport.TransportProtocol.WebSocket,
RandomizationFactor = 0.5
});
SocketClient.OnConnected += IOClient_OnConnected;
SocketClient.OnDisconnected += IOClient_OnDisconnected;
SocketClient.OnReconnectAttempt += IOClient_OnReconnectAttempt;
SocketClient.OnError += IOClient_OnError;
SocketClient.On("pong", response =>
{
Logger.Debug($"pong (server) at {response}");
});
Logger.Debug("Try to connect...");
await SocketClient.ConnectAsync();
}
catch (Exception ex)
{
if (CancellationTokenSource.IsCancellationRequested) return;
Logger.Error(ex.Message);
StopNode();
Process.GetCurrentProcess().Kill();
}
}
private async void IOClient_OnConnected(object sender, EventArgs e)
{
var socket = sender as SocketIO;
Logger.Info($"Socket_OnConnected Socket.Id: {socket.Id}");
while (SocketClient.Connected)
{
if (CancellationTokenSource.IsCancellationRequested) return;
await Task.Delay(PingInterval);
if (!SocketClient.Connected)
break;
await SocketClient.EmitAsync("ping", DateTime.UtcNow.ToString());
}
}
private void IOClient_OnDisconnected(object sender, string e)
{
Logger.Debug($"Socket_OnDisconnected {e}");
}
private void IOClient_OnReconnectAttempt(object sender, int attempt)
{
Logger.Debug($"Try to reconnect... attempt {attempt}");
if (attempt >= ReconnectAttempts)
{
StopPing();
Process.GetCurrentProcess().Kill();
}
}
private void IOClient_OnError(object sender, string e)
{
Logger.Error($"IOClient_OnError {e}");
}
private void StopPing()
{
try
{
if (SocketClient != null)
{
SocketClient.OnConnected -= IOClient_OnConnected;
SocketClient.OnDisconnected -= IOClient_OnDisconnected;
SocketClient.OnReconnectAttempt -= IOClient_OnReconnectAttempt;
SocketClient.OnError -= IOClient_OnError;
SocketClient.Dispose();
SocketClient = null;
}
CancellationTokenSource.Cancel();
}
catch (Exception ex)
{
Logger.Error($"Ping failed stop {ex.Message}");
StopNode();
Process.GetCurrentProcess().Kill();
}
}
}
}

View File

@ -1,13 +0,0 @@
namespace ASC.Socket.IO.Svc
{
public class SocketSettings
{
public string Path { get; set; }
public string Port { get; set; }
public string RedisHost { get; set; }
public string RedisPort { get; set; }
public int? PingInterval { get; set; }
public int? ReconnectAttempts { get; set; }
}
}

View File

@ -1,3 +0,0 @@
{
"pathToConf": "..\\..\\..\\config"
}

View File

@ -1,34 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<GenerateMvcApplicationPartsAssemblyAttributes>false</GenerateMvcApplicationPartsAssemblyAttributes>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
<PackageReference Include="StackExchange.Redis.Extensions.AspNetCore" Version="7.2.1" />
<PackageReference Include="StackExchange.Redis.Extensions.Newtonsoft" Version="7.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ASC.Api.Core\ASC.Api.Core.csproj" />
<ProjectReference Include="..\..\ASC.Common\ASC.Common.csproj" />
<ProjectReference Include="..\..\ASC.Data.Encryption\ASC.Data.Encryption.csproj" />
</ItemGroup>
</Project>

View File

@ -1,119 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Utils;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
namespace ASC.SsoAuth.Svc
{
[Singletone]
public class Launcher : IHostedService
{
private ProcessStartInfo startInfo;
private Process proc;
private string LogDir { get; set; }
private ILog Logger { get; set; }
private IConfiguration Configuration { get; }
private ConfigurationExtension ConfigurationExtension { get; }
private IHostEnvironment HostEnvironment { get; }
public Launcher(
IOptionsMonitor<ILog> options,
IConfiguration configuration,
ConfigurationExtension configurationExtension,
IHostEnvironment hostEnvironment)
{
Logger = options.CurrentValue;
Configuration = configuration;
ConfigurationExtension = configurationExtension;
HostEnvironment = hostEnvironment;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
try
{
var cfg = ConfigurationExtension.GetSetting<SsoAuthSettings>("ssoauth");
startInfo = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
FileName = "node",
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = $"\"{Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, cfg.Path, "app.js"))}\"",
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory
};
startInfo.EnvironmentVariables.Add("core.machinekey", Configuration["core:machinekey"]);
startInfo.EnvironmentVariables.Add("port", cfg.Port);
LogDir = Logger.LogDirectory;
startInfo.EnvironmentVariables.Add("logPath", LogDir);
await StartNode(cancellationToken);
}
catch (Exception e)
{
Logger.Error("Start", e);
}
}
public Task StopAsync(CancellationToken cancellationToken)
{
try
{
if (proc != null && !proc.HasExited)
{
proc.Kill();
proc.WaitForExit(10000);
proc.Close();
proc.Dispose();
proc = null;
}
}
catch (Exception e)
{
Logger.Error("Stop", e);
}
return Task.CompletedTask;
}
private async Task StartNode(CancellationToken cancellationToken)
{
await StopAsync(cancellationToken);
proc = Process.Start(startInfo);
}
}
}

View File

@ -1,130 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2020
*
* 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 § 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 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using ASC.Api.Core;
using ASC.Common;
using ASC.Common.Caching;
using ASC.Common.DependencyInjection;
using ASC.Common.Utils;
using ASC.SsoAuth.Svc;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StackExchange.Redis.Extensions.Core.Configuration;
using StackExchange.Redis.Extensions.Newtonsoft;
namespace ASC.Socket.IO.Svc
{
public class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSystemd()
.UseWindowsService()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<BaseWorkerStartup>())
.ConfigureAppConfiguration((hostContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production");
config
.AddJsonFile("appsettings.json")
.AddJsonFile("storage.json")
.AddJsonFile("kafka.json")
.AddJsonFile($"kafka.{env}.json", true)
.AddJsonFile("redis.json")
.AddJsonFile($"redis.{env}.json", true)
.AddJsonFile("ssoauth.json")
.AddJsonFile($"appsettings.{env}.json", true)
.AddJsonFile($"ssoauth.{env}.json", true)
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path }
}
);
})
.ConfigureServices((hostContext, services) =>
{
services.AddMemoryCache();
var diHelper = new DIHelper(services);
var redisConfiguration = hostContext.Configuration.GetSection("Redis").Get<RedisConfiguration>();
var kafkaConfiguration = hostContext.Configuration.GetSection("kafka").Get<KafkaSettings>();
if (kafkaConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(KafkaCache<>));
}
else if (redisConfiguration != null)
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(RedisCache<>));
services.AddStackExchangeRedisExtensions<NewtonsoftSerializer>(redisConfiguration);
}
else
{
diHelper.TryAdd(typeof(ICacheNotify<>), typeof(MemoryCacheNotify<>));
}
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
services.AddHostedService<Launcher>();
diHelper.TryAdd<Launcher>();
})
.ConfigureContainer<ContainerBuilder>((context, builder) =>
{
builder.Register(context.Configuration, false, false);
})
.ConfigureNLogLogging();
}
}

View File

@ -1,29 +0,0 @@
{
"profiles": {
"Kestrel WebServer": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "sso",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5024",
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WSL 2 : Ubuntu 20.04": {
"commandName": "WSL2",
"launchBrowser": false,
"environmentVariables": {
"$STORAGE_ROOT": "../../../Data",
"log__name": "sso",
"log__dir": "../../../Logs",
"core__products__folder": "../../../products",
"ASPNETCORE_URLS": "http://localhost:5024",
"ASPNETCORE_ENVIRONMENT": "Development"
},
"distributionName": "Ubuntu-20.04"
}
}
}

View File

@ -1,24 +0,0 @@
/*
*
* (c) Copyright Ascensio System Limited 2010-2021
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
namespace ASC.SsoAuth.Svc
{
public class SsoAuthSettings
{
public string Path { get; set; }
public string Port { get; set; }
}
}

View File

@ -1,3 +0,0 @@
{
"pathToConf": "..\\..\\..\\config"
}