diff options
author | Valery Piashchynski <[email protected]> | 2021-09-16 17:12:37 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-09-16 17:12:37 +0300 |
commit | f3491c089b4da77fd8d2bc942a88b6b8d117a8a5 (patch) | |
tree | 32bfffb1f24eeee7b909747cc00a6a6b9fd3ee83 /pkg/state | |
parent | 5d2cd55ab522d4f1e65a833f91146444465a32ac (diff) |
Move plugins to a separate repository
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/state')
-rw-r--r-- | pkg/state/job/state.go | 19 | ||||
-rw-r--r-- | pkg/state/process/state.go | 76 |
2 files changed, 0 insertions, 95 deletions
diff --git a/pkg/state/job/state.go b/pkg/state/job/state.go deleted file mode 100644 index 56050084..00000000 --- a/pkg/state/job/state.go +++ /dev/null @@ -1,19 +0,0 @@ -package job - -// State represents job's state -type State struct { - // Pipeline name - Pipeline string - // Driver name - Driver string - // Queue name (tube for the beanstalk) - Queue string - // Active jobs which are consumed from the driver but not handled by the PHP worker yet - Active int64 - // Delayed jobs - Delayed int64 - // Reserved jobs which are in the driver but not consumed yet - Reserved int64 - // Status - 1 Ready, 0 - Paused - Ready bool -} diff --git a/pkg/state/process/state.go b/pkg/state/process/state.go deleted file mode 100644 index bfc3a287..00000000 --- a/pkg/state/process/state.go +++ /dev/null @@ -1,76 +0,0 @@ -package process - -import ( - "github.com/shirou/gopsutil/process" - "github.com/spiral/errors" - "github.com/spiral/roadrunner/v2/pkg/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 -} - -func GeneralProcessState(pid int, command string) (State, error) { - const op = errors.Op("process_state") - p, _ := process.NewProcess(int32(pid)) - i, err := p.MemoryInfo() - if err != nil { - return State{}, errors.E(op, err) - } - percent, err := p.CPUPercent() - if err != nil { - return State{}, err - } - - return State{ - CPUPercent: percent, - Pid: pid, - MemoryUsage: i.RSS, - Command: command, - }, nil -} |