summaryrefslogtreecommitdiff
path: root/state
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2022-01-15 12:08:20 +0300
committerValery Piashchynski <[email protected]>2022-01-15 12:08:20 +0300
commit5254c8eb27311e2a8a53a4c90c3829cf1238c563 (patch)
treeb51c9a4c1dd4c25adc511498ce0380a7078c5572 /state
parent13609dd03dd0d2fa85b9fb850be787bf4e2ea67f (diff)
Repository content update
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'state')
-rw-r--r--state/process/state.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/state/process/state.go b/state/process/state.go
deleted file mode 100644
index d49d526f..00000000
--- a/state/process/state.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package process
-
-import (
- "github.com/shirou/gopsutil/process"
- "github.com/spiral/errors"
- "github.com/spiral/roadrunner/v2/worker"
-)
-
-// State provides information about specific worker.
-type State 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"`
-
- // CPU_Percent returns how many percent of the CPU time this process uses
- CPUPercent float64
-
- // Command used in the service plugin and shows a command for the particular service
- Command string
-}
-
-// WorkerProcessState creates new worker state definition.
-func WorkerProcessState(w worker.BaseProcess) (*State, error) {
- const op = errors.Op("worker_process_state")
- p, _ := process.NewProcess(int32(w.Pid()))
- i, err := p.MemoryInfo()
- if err != nil {
- return nil, errors.E(op, err)
- }
-
- percent, err := p.CPUPercent()
- if err != nil {
- return nil, err
- }
-
- return &State{
- CPUPercent: percent,
- Pid: int(w.Pid()),
- Status: w.State().String(),
- NumJobs: w.State().NumExecs(),
- Created: w.Created().UnixNano(),
- MemoryUsage: i.RSS,
- }, nil
-}