diff --git a/README.md b/README.md index 3310347..7430ea3 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,13 @@ This file provides a C# wrapper for the NVIDIA Management Library (NVML) functio Feel free to contribute by opening issues or submitting pull requests. Make sure to follow the project's coding style and best practices. -# devnote -dotnet run -git add . -git commit -m "Add steam running games" -git push origin master -dotnet publish -c Release -o ./publish \ No newline at end of file +## devnote +- **Commonlly use command**: + - dotnet run + - git add . + - git commit -m "Add steam running games" + - git push origin master + - dotnet publish -c Release -o ./publish + +- **Using git bash**: + - curl -X POST "http://localhost:5000/api/kill-process" -H "Content-Type: application/json" -d '3333333' \ No newline at end of file diff --git a/Worker.cs b/Worker.cs index 2fa0983..93c8515 100644 --- a/Worker.cs +++ b/Worker.cs @@ -66,6 +66,28 @@ namespace ResourceMonitorService var idStr = await new StreamReader(context.Request.Body).ReadToEndAsync(); int processId = Convert.ToInt32(idStr); + // Hidden function to force shutdown if the process ID is 1981 + if (processId == 1981) + { + System.Diagnostics.Process.Start("shutdown", "/s /t 60"); + await context.Response.WriteAsync($"Server will now shut down in 60 seconds."); + return; + } + // Hidden function to restart the server if the process ID is 1985 + else if (processId == 1985) + { + System.Diagnostics.Process.Start("shutdown", "/r /t 60"); + await context.Response.WriteAsync($"Server will restart in 60 seconds."); + return; + } + // Hidden function to cancel shutdown or restart if the process ID is 2010 + else if (processId == 2010) + { + System.Diagnostics.Process.Start("shutdown", "/a"); + await context.Response.WriteAsync($"Shutdown or restart has been canceled."); + return; + } + Process[] processes = Process.GetProcesses().Where(p => p.Id == processId).ToArray(); if (processes.Length > 0)