Update README with common commands and add hidden process control functions in Worker

This commit is contained in:
Phoenix
2024-12-27 16:39:53 +08:00
parent 5eec358b68
commit 77f6c5abe1
2 changed files with 32 additions and 6 deletions
+10 -6
View File
@@ -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
## 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'
+22
View File
@@ -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)