summaryrefslogtreecommitdiff
path: root/tools/process.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-19 16:42:28 +0300
committerValery Piashchynski <[email protected]>2021-04-19 16:42:28 +0300
commitbaa12b092578d41218585d918fb7e1425700272d (patch)
tree91881bd0ac32c609ea01fafe3bbc15a13a67c392 /tools/process.go
parent112b7b60bbc045f4935e1766be9d2266abf68b31 (diff)
- Add tests, update Informer implementation
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'tools/process.go')
-rw-r--r--tools/process.go44
1 files changed, 0 insertions, 44 deletions
diff --git a/tools/process.go b/tools/process.go
deleted file mode 100644
index a6eb1139..00000000
--- a/tools/process.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package tools
-
-import (
- "github.com/shirou/gopsutil/process"
- "github.com/spiral/errors"
- "github.com/spiral/roadrunner/v2/pkg/worker"
-)
-
-// ProcessState provides information about specific worker.
-type ProcessState struct {
- // Pid contains process id.
- Pid int `json:"pid"`
-
- // Status of the worker.
- Status string `json:"status"`
-
- // Number of worker executions.
- NumJobs uint64 `json:"numExecs"`
-
- // Created is unix nano timestamp of worker creation time.
- Created int64 `json:"created"`
-
- // MemoryUsage holds the information about worker memory usage in bytes.
- // Values might vary for different operating systems and based on RSS.
- MemoryUsage uint64 `json:"memoryUsage"`
-}
-
-// WorkerProcessState creates new worker state definition.
-func WorkerProcessState(w worker.BaseProcess) (ProcessState, error) {
- const op = errors.Op("worker_process_state")
- p, _ := process.NewProcess(int32(w.Pid()))
- i, err := p.MemoryInfo()
- if err != nil {
- return ProcessState{}, errors.E(op, err)
- }
-
- return ProcessState{
- Pid: int(w.Pid()),
- Status: w.State().String(),
- NumJobs: w.State().NumExecs(),
- Created: w.Created().UnixNano(),
- MemoryUsage: i.RSS,
- }, nil
-}