git 업데이트중 신규 요청시 재시작 할수있게 처리
This commit is contained in:
parent
a9e06490bd
commit
eb1da46328
|
@ -2,14 +2,36 @@
|
|||
{
|
||||
public abstract class AbstractGit
|
||||
{
|
||||
public bool isRestart;
|
||||
/// <summary>
|
||||
/// 가장먼저 시작해야 하는 스크립트
|
||||
/// </summary>
|
||||
public void init()
|
||||
public void Init()
|
||||
{
|
||||
isRestart = false;
|
||||
restart:
|
||||
Pull();
|
||||
//ChangeScript();
|
||||
//Push();
|
||||
|
||||
if (isRestart)
|
||||
{
|
||||
isRestart = !isRestart;
|
||||
goto restart;
|
||||
}
|
||||
|
||||
ChangeScript();
|
||||
|
||||
if (isRestart)
|
||||
{
|
||||
isRestart = !isRestart;
|
||||
goto restart;
|
||||
}
|
||||
Push();
|
||||
|
||||
if (isRestart)
|
||||
{
|
||||
isRestart = !isRestart;
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -4,7 +4,15 @@
|
|||
{
|
||||
public override void ChangeScript()
|
||||
{
|
||||
Console.WriteLine("뭔가를 작업하세요");
|
||||
for(int n = 0; n < 100; n++)
|
||||
{
|
||||
if (isRestart)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("뭔가를 작업하세요" + n);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,17 @@ using Server.System;
|
|||
var builder = WebApplication.CreateBuilder(args);
|
||||
var app = builder.Build();
|
||||
|
||||
ProtocolProcessor.init();
|
||||
//웹서버 초기화
|
||||
ProtocolProcessor.Init();
|
||||
//깃 웹훅 초기화
|
||||
GItWebhook.Init();
|
||||
|
||||
//http용 데이터
|
||||
app.MapPost("/", ProtocolProcessor.Process);
|
||||
|
||||
//git 접근용 웹훅
|
||||
app.MapPost("/git", GItWebhook.Process);
|
||||
|
||||
//app.MapPost("/update", GItWebhook.Process);
|
||||
|
||||
app.Run();
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
using NLog;
|
||||
using Server.Git;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Server.System
|
||||
{
|
||||
public class GItWebhook
|
||||
{
|
||||
private static readonly NLog.ILogger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static Thread thread;
|
||||
|
||||
private static AbstractGit git;
|
||||
|
||||
public static string Process(HttpContext context)
|
||||
{
|
||||
AbstractService abstractService;
|
||||
|
||||
//TODO 아무때나 호출되지 않게 만들기
|
||||
string Response;
|
||||
try
|
||||
{
|
||||
|
@ -22,7 +29,23 @@ namespace Server.System
|
|||
Console.WriteLine($"X-Gitea-Event-Type : {eaEventType}");
|
||||
Console.WriteLine($"X-Gitea-Signature : {eaSignature}");
|
||||
|
||||
Console.WriteLine(thread.ThreadState);
|
||||
|
||||
//Unstarted
|
||||
if (thread.ThreadState == ThreadState.Unstarted)
|
||||
{
|
||||
thread.Start();
|
||||
}
|
||||
else if (thread.ThreadState == ThreadState.Stopped)
|
||||
{
|
||||
thread = new Thread(git.Init);
|
||||
thread.Start();
|
||||
}
|
||||
else if (thread.ThreadState == ThreadState.WaitSleepJoin || thread.ThreadState == ThreadState.Running)
|
||||
{
|
||||
git.isRestart = true;
|
||||
}
|
||||
|
||||
|
||||
ErrorResp error = new ErrorResp();
|
||||
error.status = 200;
|
||||
|
@ -44,5 +67,11 @@ namespace Server.System
|
|||
return Response;
|
||||
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
git = new XlsxToJson();
|
||||
thread = new Thread(git.Init);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Server.System {
|
|||
SERVICE_DIC.Add(abstractService.ProtocolValue(), abstractService);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
public static void Init() {
|
||||
// 현재 실행 중인 어셈블리를 가져옴
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,76 @@
|
|||
2023-11-19 14:56:20.0361|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 14:56:37.1023|ERROR|Server.System.GItWebhook|GetErrorResponse : System.Threading.ThreadStateException: Thread is running or terminated; it cannot restart.
|
||||
at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName)
|
||||
at System.Threading.Thread.StartCore()
|
||||
at System.Threading.Thread.Start(Boolean captureContext)
|
||||
at System.Threading.Thread.Start()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 32
|
||||
2023-11-19 14:56:40.9259|ERROR|Server.System.GItWebhook|GetErrorResponse : System.Threading.ThreadStateException: Thread is running or terminated; it cannot restart.
|
||||
at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName)
|
||||
at System.Threading.Thread.StartCore()
|
||||
at System.Threading.Thread.Start(Boolean captureContext)
|
||||
at System.Threading.Thread.Start()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 32
|
||||
2023-11-19 14:56:42.2523|ERROR|Server.System.GItWebhook|GetErrorResponse : System.Threading.ThreadStateException: Thread is running or terminated; it cannot restart.
|
||||
at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName)
|
||||
at System.Threading.Thread.StartCore()
|
||||
at System.Threading.Thread.Start(Boolean captureContext)
|
||||
at System.Threading.Thread.Start()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 32
|
||||
2023-11-19 14:56:45.5190|ERROR|Server.System.GItWebhook|GetErrorResponse : System.Threading.ThreadStateException: Thread is running or terminated; it cannot restart.
|
||||
at System.Threading.Thread.StartInternal(ThreadHandle t, Int32 stackSize, Int32 priority, Char* pThreadName)
|
||||
at System.Threading.Thread.StartCore()
|
||||
at System.Threading.Thread.Start(Boolean captureContext)
|
||||
at System.Threading.Thread.Start()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 32
|
||||
2023-11-19 14:59:45.3242|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 14:59:54.7574|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 15:00:11.3099|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 15:00:42.1291|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:00:47.7832|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 36
|
||||
2023-11-19 15:18:57.1278|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:22:14.6405|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:22:38.6975|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:23:07.2232|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:24:13.9673|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:25:46.4718|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:27:21.7466|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:27:26.4967|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 34
|
||||
2023-11-19 15:27:28.6315|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 34
|
||||
2023-11-19 15:28:46.7554|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:28:53.2138|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 34
|
||||
2023-11-19 15:53:52.3423|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 15:53:57.1433|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 15:53:59.5704|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 15:54:02.7564|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 15:54:03.8472|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 15:54:04.6437|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 15:54:05.7834|ERROR|Server.System.GItWebhook|GetErrorResponse : System.PlatformNotSupportedException: Thread abort is not supported on this platform.
|
||||
at System.Threading.Thread.Abort()
|
||||
at Server.System.GItWebhook.Process(HttpContext context) in E:\git\CsServer\Server\System\GItWebhook.cs:line 35
|
||||
2023-11-19 16:00:22.8126|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 16:05:38.2708|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 16:08:18.6752|INFO|Server.System.ProtocolProcessor|Server Start
|
||||
2023-11-19 16:12:50.9169|INFO|Server.System.ProtocolProcessor|Server Start
|
Binary file not shown.
|
@ -8,13 +8,84 @@
|
|||
".NETCoreApp,Version=v6.0": {
|
||||
"Server/1.0.0": {
|
||||
"dependencies": {
|
||||
"NLog": "5.2.0",
|
||||
"LibGit2Sharp": "0.28.0",
|
||||
"NLog": "5.2.5",
|
||||
"Newtonsoft.Json": "13.0.3"
|
||||
},
|
||||
"runtime": {
|
||||
"Server.dll": {}
|
||||
}
|
||||
},
|
||||
"LibGit2Sharp/0.28.0": {
|
||||
"dependencies": {
|
||||
"LibGit2Sharp.NativeBinaries": "2.0.320"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net6.0/LibGit2Sharp.dll": {
|
||||
"assemblyVersion": "0.28.0.0",
|
||||
"fileVersion": "0.28.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"LibGit2Sharp.NativeBinaries/2.0.320": {
|
||||
"runtimeTargets": {
|
||||
"runtimes/linux-arm/native/libgit2-e632535.so": {
|
||||
"rid": "linux-arm",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/linux-arm64/native/libgit2-e632535.so": {
|
||||
"rid": "linux-arm64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/linux-musl-arm/native/libgit2-e632535.so": {
|
||||
"rid": "linux-musl-arm",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/linux-musl-arm64/native/libgit2-e632535.so": {
|
||||
"rid": "linux-musl-arm64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/linux-musl-x64/native/libgit2-e632535.so": {
|
||||
"rid": "linux-musl-x64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/linux-x64/native/libgit2-e632535.so": {
|
||||
"rid": "linux-x64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/osx-arm64/native/libgit2-e632535.dylib": {
|
||||
"rid": "osx-arm64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/osx-x64/native/libgit2-e632535.dylib": {
|
||||
"rid": "osx-x64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "0.0.0.0"
|
||||
},
|
||||
"runtimes/win-arm64/native/git2-e632535.dll": {
|
||||
"rid": "win-arm64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "1.6.4.0"
|
||||
},
|
||||
"runtimes/win-x64/native/git2-e632535.dll": {
|
||||
"rid": "win-x64",
|
||||
"assetType": "native",
|
||||
"fileVersion": "1.6.4.0"
|
||||
},
|
||||
"runtimes/win-x86/native/git2-e632535.dll": {
|
||||
"rid": "win-x86",
|
||||
"assetType": "native",
|
||||
"fileVersion": "1.6.4.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"runtime": {
|
||||
"lib/net6.0/Newtonsoft.Json.dll": {
|
||||
|
@ -23,11 +94,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"NLog/5.2.0": {
|
||||
"NLog/5.2.5": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/NLog.dll": {
|
||||
"assemblyVersion": "5.0.0.0",
|
||||
"fileVersion": "5.2.0.1813"
|
||||
"fileVersion": "5.2.5.2160"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +110,20 @@
|
|||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"LibGit2Sharp/0.28.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-+VGXLAQovtTc41EkUXBKSuu40XcyuWUmQrslpd0CPMGkpnLTgQwoRLSSCRxLSPjYSi9SskyRUOLa9tjg/L108A==",
|
||||
"path": "libgit2sharp/0.28.0",
|
||||
"hashPath": "libgit2sharp.0.28.0.nupkg.sha512"
|
||||
},
|
||||
"LibGit2Sharp.NativeBinaries/2.0.320": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-7vIqOhB+5LOi9arXi8IdlkWURpQEiMtnwVP//djA7cQvIVfpC4bZSnQIDe4kwwvsU/w1oH0YkBTgMmpkVndNbg==",
|
||||
"path": "libgit2sharp.nativebinaries/2.0.320",
|
||||
"hashPath": "libgit2sharp.nativebinaries.2.0.320.nupkg.sha512"
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
|
@ -46,12 +131,12 @@
|
|||
"path": "newtonsoft.json/13.0.3",
|
||||
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
|
||||
},
|
||||
"NLog/5.2.0": {
|
||||
"NLog/5.2.5": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-uYBgseY0m/9lQUbZYGsQsTBFOWrfs3iaekzzYMH6vFmpoOAvV8/bp1XxG/suZkwB5h8nAiTJAp7VENWRDKtKPA==",
|
||||
"path": "nlog/5.2.0",
|
||||
"hashPath": "nlog.5.2.0.nupkg.sha512"
|
||||
"sha512": "sha512-mMXtbAxfNzqkXcBjhJ3wN3rH7kwUZ0JL0GrUBI/lso7+tQ/HC4e5SnlmR3R5qQ9zWbqMbjxeH37rIf0yQGWTiA==",
|
||||
"path": "nlog/5.2.5",
|
||||
"hashPath": "nlog.5.2.5.nupkg.sha512"
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
0ebb13e4726a5860df23c6995ec57867292f8af6
|
||||
8a3f59ad2a2c5f468fbf79e1d66b8b9279df41d9
|
||||
|
|
|
@ -111,3 +111,15 @@ E:\git\CsServer\Server\obj\Debug\net6.0\refint\Server.dll
|
|||
E:\git\CsServer\Server\obj\Debug\net6.0\Server.pdb
|
||||
E:\git\CsServer\Server\obj\Debug\net6.0\Server.genruntimeconfig.cache
|
||||
E:\git\CsServer\Server\obj\Debug\net6.0\ref\Server.dll
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\LibGit2Sharp.dll
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\linux-arm\native\libgit2-e632535.so
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\linux-arm64\native\libgit2-e632535.so
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\linux-musl-arm\native\libgit2-e632535.so
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\linux-musl-arm64\native\libgit2-e632535.so
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\linux-musl-x64\native\libgit2-e632535.so
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\linux-x64\native\libgit2-e632535.so
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\osx-arm64\native\libgit2-e632535.dylib
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\osx-x64\native\libgit2-e632535.dylib
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\win-arm64\native\git2-e632535.dll
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\win-x64\native\git2-e632535.dll
|
||||
E:\git\CsServer\Server\bin\Debug\net6.0\runtimes\win-x86\native\git2-e632535.dll
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue