process_utils

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProcessRunningCode = iota
	ProcessStoppedCode
	ProcessDeadCode
)

Variables

View Source
var (
	ProcStateRunning = ProcessState{
		Code:        ProcessRunningCode,
		ColorSprint: color.New(color.FgGreen).SprintFunc(),
		Status:      "RUNNING"}
	ProcStateStopped = ProcessState{
		Code:        ProcessStoppedCode,
		ColorSprint: color.New(color.FgYellow).SprintFunc(),
		Status:      "NOT RUNNING"}
	ProcStateDead = ProcessState{
		Code:        ProcessDeadCode,
		ColorSprint: color.New(color.FgRed).SprintFunc(),
		Status:      "ERROR. The process is dead"}
)

Functions

func CheckPIDFile

func CheckPIDFile(pidFileName string) error

CheckPIDFile checks that the process PID file exists and is readable. Or process is already exist. Removes PID file if process is dead.

func CreatePIDFile

func CreatePIDFile(pidFileName string) error

CreatePIDFile checks that the instance PID file is absent or deprecated and creates a new one. Returns an error on failure.

func GetPIDFromFile

func GetPIDFromFile(pidFileName string) (int, error)

GetPIDFromFile returns PID from the PIDFile.

func IsProcessAlive

func IsProcessAlive(pid int) (bool, error)

IsProcessAlive checks if the process is alive.

func StopProcess

func StopProcess(pidFile string) (int, error)

StopProcess stops the process by pidFile.

Types

type ProcessState added in v0.4.0

type ProcessState struct {
	Code        int
	ColorSprint func(a ...interface{}) string
	Status      string
	PID         int
}

func ProcessStatus

func ProcessStatus(pidFile string) ProcessState

ProcessStatus returns the status of the process.

func (ProcessState) String added in v1.1.1

func (procState ProcessState) String() string

String makes a string from ProcessState.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL