Compare commits
1 Commits
294438145a
...
vm-branch
| Author | SHA1 | Date | |
|---|---|---|---|
| e19e1e0137 |
@@ -5,3 +5,8 @@ git add .
|
|||||||
git commit -m "Add steam running games"
|
git commit -m "Add steam running games"
|
||||||
git push origin master
|
git push origin master
|
||||||
dotnet publish -c Release -o ./publish
|
dotnet publish -c Release -o ./publish
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl -X POST "http://<your-service-hostname-or-IP>:<port>/api/kill-process?id=<PID>"
|
||||||
@@ -50,11 +50,56 @@ namespace ResourceMonitorService
|
|||||||
await context.Response.WriteAsync(json);
|
await context.Response.WriteAsync(json);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.MapPost("/api/kill-process", async context =>
|
||||||
|
{
|
||||||
|
await Results.Ok($"Macam celaka Process ni. ").ExecuteAsync(context);
|
||||||
|
/* try
|
||||||
|
{
|
||||||
|
int pid;
|
||||||
|
if (!int.TryParse(context.Request.Query["id"], out pid))
|
||||||
|
{
|
||||||
|
await Results.BadRequest("Invalid process ID.").ExecuteAsync(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await KillProcessByIdAsync(pid); // Ensure KillProcessByIdAsync returns a Task<bool>
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
await Results.Ok($"Process with PID {pid} has been terminated successfully.").ExecuteAsync(context);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Results.NotFound($"No process found with PID {pid}.").ExecuteAsync(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Log the exception or handle it as needed
|
||||||
|
await Results.Problem(ex.Message).ExecuteAsync(context);
|
||||||
|
} */
|
||||||
|
});
|
||||||
|
|
||||||
app.RunAsync(stoppingToken);
|
app.RunAsync(stoppingToken);
|
||||||
|
|
||||||
await Task.Delay(Timeout.Infinite, stoppingToken);
|
await Task.Delay(Timeout.Infinite, stoppingToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<bool> KillProcessByIdAsync(int pid)
|
||||||
|
{
|
||||||
|
using (Process process = Process.GetProcessById(pid))
|
||||||
|
{
|
||||||
|
if (process != null)
|
||||||
|
{
|
||||||
|
await Task.Run(() => process.Kill());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private object GetComputerInfo()
|
private object GetComputerInfo()
|
||||||
{
|
{
|
||||||
return new
|
return new
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:5000"
|
"Url": "http://*:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:5000"
|
"Url": "http://*:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://localhost:5000"
|
"Url": "http://*:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5000"
|
"Url": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5000"
|
"Url": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:5000"
|
"Url": "http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7dc90104512834ceb810324f20a2b5d12de354c0")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a2ea577efb4958acb8c684ca7c44c46a5650fc58")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyProductAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("ResourceMonitorService")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("ResourceMonitorService")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1212cb7eab016db3876a66a85bc18562ffabead52c3b48120f48f729d68cf190
|
f5c81f81ba8169806dd1ace73d9b0713e8716dc78a8082103d35e96cfb732d36
|
||||||
|
|||||||
@@ -62,3 +62,15 @@ D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish
|
|||||||
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.Development.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\appsettings.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.deps.json
|
||||||
|
D:\din\dev\vmsvc\ResourceMonitorService\bin\Debug\net9.0\publish\publish\publish\publish\publish\publish\publish\publish\publish\ResourceMonitorService.runtimeconfig.json
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
c65d161a800b1338fd7f033a5bc5016a31718066a3178665c8d03d56bd044a0a
|
3c41a5e0f936ad1402ac65b413d5b378ce34a9573acfd72fc7ebde791d66f502
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user