feat: implement headless server mode with API endpoints for metrics and process management

This commit is contained in:
Jonathan Atta
2026-03-11 17:51:12 +01:00
parent e7c8e66889
commit 29e8f9b887
3 changed files with 261 additions and 0 deletions

View File

@@ -313,6 +313,26 @@ func KillProcess(pid int32, force bool) error {
}
return p.Terminate()
}
// CollectFull gathers a complete metrics snapshot including GPU data.
// Unlike NewSysInfo, it does not start a background emitter and does not
// require a Wails runtime context — safe to call from server mode.
func CollectFull(ctx context.Context) (*Metrics, error) {
s := &SysInfo{ctx: ctx}
m, err := s.CollectOnce()
if err != nil {
return nil, err
}
name, tot, used, util := queryGPU(ctx)
if name != "" {
m.GPUName = name
m.GPUTotal = tot
m.GPUUsed = used
m.GPUUtil = util
m.GPUProcesses = queryGPUProcesses(ctx)
}
return m, nil
}
// GetManPage returns the plain-text man page for the given command name.
// Returns an empty string if man is not installed or the page does not exist.
func GetManPage(name string) string {