Skip to content

Commit 5ebd70a

Browse files
committed
use new procinfo package, and update API to be windowed + a quick filter
1 parent cbac0b1 commit 5ebd70a

9 files changed

Lines changed: 545 additions & 3 deletions

File tree

frontend/app/store/wshclientapi.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,18 @@ export class RpcApiType {
756756
return client.wshRpcCall("remotemkdir", data, opts);
757757
}
758758

759+
// command "remoteprocesslist" [call]
760+
RemoteProcessListCommand(client: WshClient, data: CommandRemoteProcessListData, opts?: RpcOpts): Promise<ProcessListResponse> {
761+
if (this.mockClient) return this.mockClient.mockWshRpcCall(client, "remoteprocesslist", data, opts);
762+
return client.wshRpcCall("remoteprocesslist", data, opts);
763+
}
764+
765+
// command "remoteprocesssignal" [call]
766+
RemoteProcessSignalCommand(client: WshClient, data: CommandRemoteProcessSignalData, opts?: RpcOpts): Promise<void> {
767+
if (this.mockClient) return this.mockClient.mockWshRpcCall(client, "remoteprocesssignal", data, opts);
768+
return client.wshRpcCall("remoteprocesssignal", data, opts);
769+
}
770+
759771
// command "remotereconnecttojobmanager" [call]
760772
RemoteReconnectToJobManagerCommand(client: WshClient, data: CommandRemoteReconnectToJobManagerData, opts?: RpcOpts): Promise<CommandRemoteReconnectToJobManagerRtnData> {
761773
if (this.mockClient) return this.mockClient.mockWshRpcCall(client, "remotereconnecttojobmanager", data, opts);

frontend/types/gotypes.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,21 @@ declare global {
557557
fileinfo?: FileInfo[];
558558
};
559559

560+
// wshrpc.CommandRemoteProcessListData
561+
type CommandRemoteProcessListData = {
562+
sortby?: string;
563+
sortdesc?: boolean;
564+
start?: number;
565+
limit?: number;
566+
textsearch?: string;
567+
};
568+
569+
// wshrpc.CommandRemoteProcessSignalData
570+
type CommandRemoteProcessSignalData = {
571+
pid: number;
572+
signal: string;
573+
};
574+
560575
// wshrpc.CommandRemoteReconnectToJobManagerData
561576
type CommandRemoteReconnectToJobManagerData = {
562577
jobid: string;
@@ -1244,6 +1259,39 @@ declare global {
12441259
y: number;
12451260
};
12461261

1262+
// wshrpc.ProcessInfo
1263+
type ProcessInfo = {
1264+
pid: number;
1265+
ppid?: number;
1266+
command?: string;
1267+
status?: string;
1268+
user?: string;
1269+
mem?: number;
1270+
mempct?: number;
1271+
cpu?: number;
1272+
numthreads?: number;
1273+
};
1274+
1275+
// wshrpc.ProcessListResponse
1276+
type ProcessListResponse = {
1277+
processes: ProcessInfo[];
1278+
summary: ProcessSummary;
1279+
ts: number;
1280+
hascpu?: boolean;
1281+
iswindows?: boolean;
1282+
};
1283+
1284+
// wshrpc.ProcessSummary
1285+
type ProcessSummary = {
1286+
total: number;
1287+
load1?: number;
1288+
load5?: number;
1289+
load15?: number;
1290+
memtotal?: number;
1291+
memused?: number;
1292+
memfree?: number;
1293+
};
1294+
12471295
// uctypes.RateLimitInfo
12481296
type RateLimitInfo = {
12491297
req: number;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/util/procinfo/procinfo_darwin.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"golang.org/x/sys/unix"
1313
)
1414

15-
1615
// darwinStatStatus maps P_stat from ExternProc to a human-readable name.
1716
// Values from sys/proc.h: SIDL=1, SRUN=2, SSLEEP=3, SSTOP=4, SZOMB=5, SDEAD=6.
1817
var darwinStatStatus = map[int8]string{

pkg/util/unixutil/unixutil_unix.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,15 @@ func IsPidRunning(pid int) bool {
8080
}
8181
return false
8282
}
83+
84+
func SendSignalByName(pid int, sigName string) error {
85+
sig := ParseSignal(sigName)
86+
if sig == nil {
87+
return fmt.Errorf("unsupported or invalid signal %q", sigName)
88+
}
89+
p, err := os.FindProcess(pid)
90+
if err != nil {
91+
return fmt.Errorf("process %d not found: %w", pid, err)
92+
}
93+
return p.Signal(sig)
94+
}

pkg/util/unixutil/unixutil_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ func SignalHup(pid int) error {
4444
func IsPidRunning(pid int) bool {
4545
return false
4646
}
47+
48+
func SendSignalByName(pid int, sigName string) error {
49+
return fmt.Errorf("sending signals is not supported on Windows")
50+
}

pkg/wshrpc/wshclient/wshclient.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,18 @@ func RemoteMkdirCommand(w *wshutil.WshRpc, data string, opts *wshrpc.RpcOpts) er
753753
return err
754754
}
755755

756+
// command "remoteprocesslist", wshserver.RemoteProcessListCommand
757+
func RemoteProcessListCommand(w *wshutil.WshRpc, data wshrpc.CommandRemoteProcessListData, opts *wshrpc.RpcOpts) (*wshrpc.ProcessListResponse, error) {
758+
resp, err := sendRpcRequestCallHelper[*wshrpc.ProcessListResponse](w, "remoteprocesslist", data, opts)
759+
return resp, err
760+
}
761+
762+
// command "remoteprocesssignal", wshserver.RemoteProcessSignalCommand
763+
func RemoteProcessSignalCommand(w *wshutil.WshRpc, data wshrpc.CommandRemoteProcessSignalData, opts *wshrpc.RpcOpts) error {
764+
_, err := sendRpcRequestCallHelper[any](w, "remoteprocesssignal", data, opts)
765+
return err
766+
}
767+
756768
// command "remotereconnecttojobmanager", wshserver.RemoteReconnectToJobManagerCommand
757769
func RemoteReconnectToJobManagerCommand(w *wshutil.WshRpc, data wshrpc.CommandRemoteReconnectToJobManagerData, opts *wshrpc.RpcOpts) (*wshrpc.CommandRemoteReconnectToJobManagerRtnData, error) {
758770
resp, err := sendRpcRequestCallHelper[*wshrpc.CommandRemoteReconnectToJobManagerRtnData](w, "remotereconnecttojobmanager", data, opts)

0 commit comments

Comments
 (0)