mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 02:39:29 +08:00
featrue:支持安装为windows服务
This commit is contained in:
parent
9d3295df5e
commit
1fb3d77c01
|
@ -7,6 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0-preview.4.21253.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="6.0.0-preview.4.21253.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="5.0.3" />
|
||||
|
@ -16,6 +17,15 @@
|
|||
<ProjectReference Include="..\FastTunnel.Core\FastTunnel.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="卸载服务.bat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="安装服务.bat">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties config_4appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace FastTunnel.Server
|
|||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.UseWindowsService()
|
||||
.ConfigureWebHost(webHostBuilder =>
|
||||
{
|
||||
webHostBuilder.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
|
@ -25,7 +26,6 @@ namespace FastTunnel.Server
|
|||
var env = hostingContext.HostingEnvironment;
|
||||
config.AddJsonFile("config/appsettings.json", optional: true, reloadOnChange: true)
|
||||
.AddJsonFile($"config/appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
||||
|
||||
});
|
||||
})
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
|
|
10
FastTunnel.Server/卸载服务.bat
Normal file
10
FastTunnel.Server/卸载服务.bat
Normal file
|
@ -0,0 +1,10 @@
|
|||
@echo off
|
||||
color 0e
|
||||
@echo ==================================
|
||||
@echo 提醒:请右键本文件,用管理员方式打开。
|
||||
@echo ==================================
|
||||
@echo Start Remove FastTunnel.Server Service
|
||||
|
||||
Net stop FastTunnel.Server
|
||||
sc delete FastTunnel.Server
|
||||
pause
|
11
FastTunnel.Server/安装服务.bat
Normal file
11
FastTunnel.Server/安装服务.bat
Normal file
|
@ -0,0 +1,11 @@
|
|||
@echo off
|
||||
color 0e
|
||||
@echo ==================================
|
||||
@echo 提醒:请右键本文件,用管理员方式打开。
|
||||
@echo ==================================
|
||||
@echo Start Install FastTunnel.Server Service
|
||||
|
||||
sc create FastTunnel.Server binPath=%~dp0\FastTunnel.Server.exe start= auto
|
||||
sc description FastTunnel.Server "FastTunnel-开源内网穿透服务,仓库地址:https://github.com/SpringHgui/FastTunnel star项目以支持作者"
|
||||
Net Start FastTunnel.Server
|
||||
pause
|
Loading…
Reference in New Issue
Block a user