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
+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)