Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPidNotFound raised when a pid cannot be by querying the OS ErrPidNotFound = errors.New("pid not found") // ErrPIDInvalid raised when an invalid pid is parsed from a pidfile ErrPIDInvalid = errors.New("pid wasn't valid") // ErrFailedToAcquirePidLock raised when a lock acquisition times out or fails due to contention ErrFailedToAcquirePidLock = errors.New("failed to acquire lock on pidfile") // ErrFailedToWritePidFile raised when the pid cannot be written to the pidfile ErrFailedToWritePidFile = errors.New("failed to write pidfile") // ErrFailedToStartProc we failed to call os.Exec ErrFailedToStartProc = errors.New("failed to start process") // ErrFailedToDetach we started the process but failed to orphan it ErrFailedToDetach = errors.New("failed to detach from process") // ErrAlreadyRunning raised by Proc.Init when a pid is active ErrAlreadyRunning = errors.New("cannot init process pid is already running") // ErrTimeout is raised when we fail to stop a process ErrTimeout = errors.New("an operation timed out") )
Functions ¶
func FindProcess ¶
FindProcess attempts to locate a process by its pid returns a wrapped ErrPidNotFound if the process cannot be signaled
func Fork ¶
Fork allows a program to be started and orphaned This process will exit without cleaning up its child process It is highly recommended managing the PID returned from this function
func LoadPidFile ¶
LoadPidFile opens a pidfile and parses its value as an integer
Types ¶
type Proc ¶
type Proc struct {
// contains filtered or unexported fields
}
Proc a struct that houses data for managing a process
func (*Proc) Init ¶
Init attempts to validate if a process is already running at the given pidfile If the process is already running no action is taken If the process isn't running we attempt to acquire a lock pidfile We then start the process and store its pid in the pidfile and release the lock