feat: implement headless server mode with API endpoints for metrics and process management
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user