尝试结束占用https的进程
This commit is contained in:
parent
ec4d8d5607
commit
bed28c53b9
@ -30,8 +30,18 @@ namespace FastGithub.ReverseProxy
|
|||||||
const int HTTPSPORT = 443;
|
const int HTTPSPORT = 443;
|
||||||
if (TcpTable.TryGetOwnerProcessId(HTTPSPORT, out var pid))
|
if (TcpTable.TryGetOwnerProcessId(HTTPSPORT, out var pid))
|
||||||
{
|
{
|
||||||
var process = Process.GetProcessById(pid);
|
try
|
||||||
this.logger.LogError($"由于进程{process.ProcessName}({pid})占用了{HTTPSPORT}端口,{nameof(FastGithub)}的反向代理无法工作");
|
{
|
||||||
|
Process.GetProcessById(pid).Kill();
|
||||||
|
}
|
||||||
|
catch (ArgumentException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
var processName = Process.GetProcessById(pid).ProcessName;
|
||||||
|
this.logger.LogError($"由于进程{processName}({pid})占用了{HTTPSPORT}端口,{nameof(FastGithub)}的反向代理无法工作");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user