Documentation ¶
Index ¶
- Constants
- Variables
- type Events
- type ManagedProcess
- func (mp *ManagedProcess) GetData() *ProcessData
- func (mp *ManagedProcess) GetExitState() (int, time.Time, error)
- func (mp *ManagedProcess) GetId() string
- func (mp *ManagedProcess) GetInnerRunningProcess() (*os.Process, error)
- func (mp *ManagedProcess) GetPid() int
- func (mp *ManagedProcess) GetRestarts() uint32
- func (mp *ManagedProcess) GetRunningProcess() (*process.Process, error)
- func (mp *ManagedProcess) GetStatus() string
- func (mp *ManagedProcess) GetStdoutPath() string
- func (mp *ManagedProcess) IsRunning() bool
- func (mp *ManagedProcess) Restart() error
- func (mp *ManagedProcess) Stop() error
- func (mp *ManagedProcess) String() string
- type Manager
- type ProcessData
- type ProcessExitEvent
- type ProcessForceRestartEvent
- type ProcessList
- type ProcessSpawnEvent
Constants ¶
View Source
const ( STATUS_RUNNING = "running" STATUS_RESTARTING = "restarting" STATUS_STOPPED = "stopped" STATUS_FAILED = "failed" )
View Source
const DEFAULT_RESTART_DELAY = time.Second * 10
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Events ¶
type Events struct { OnProcessExit *event.Event[ProcessExitEvent] OnProcessSpawn *event.Event[ProcessSpawnEvent] OnProcessForceRestart *event.Event[ProcessForceRestartEvent] }
type ManagedProcess ¶
type ManagedProcess struct {
// contains filtered or unexported fields
}
func NewManagedProcess ¶
func NewManagedProcess(manager *Manager, data *ProcessData) *ManagedProcess
func (*ManagedProcess) GetData ¶
func (mp *ManagedProcess) GetData() *ProcessData
func (*ManagedProcess) GetExitState ¶
func (mp *ManagedProcess) GetExitState() (int, time.Time, error)
func (*ManagedProcess) GetId ¶
func (mp *ManagedProcess) GetId() string
func (*ManagedProcess) GetInnerRunningProcess ¶
func (mp *ManagedProcess) GetInnerRunningProcess() (*os.Process, error)
func (*ManagedProcess) GetPid ¶
func (mp *ManagedProcess) GetPid() int
func (*ManagedProcess) GetRestarts ¶
func (mp *ManagedProcess) GetRestarts() uint32
func (*ManagedProcess) GetRunningProcess ¶
func (mp *ManagedProcess) GetRunningProcess() (*process.Process, error)
func (*ManagedProcess) GetStatus ¶
func (mp *ManagedProcess) GetStatus() string
func (*ManagedProcess) GetStdoutPath ¶
func (mp *ManagedProcess) GetStdoutPath() string
func (*ManagedProcess) IsRunning ¶
func (mp *ManagedProcess) IsRunning() bool
func (*ManagedProcess) Restart ¶
func (mp *ManagedProcess) Restart() error
func (*ManagedProcess) Stop ¶
func (mp *ManagedProcess) Stop() error
func (*ManagedProcess) String ¶
func (mp *ManagedProcess) String() string
type Manager ¶
type Manager struct { Processes *ProcessList Event *Events // contains filtered or unexported fields }
func (*Manager) Create ¶
func (m *Manager) Create(data *ProcessData) (*ManagedProcess, error)
func (*Manager) Remove ¶
func (m *Manager) Remove(process *ManagedProcess)
func (*Manager) UpdateConfiguration ¶
func (m *Manager) UpdateConfiguration( process *ManagedProcess, update func(currentConfig *pb.ProcessConfiguration) (*pb.ProcessConfiguration, error), ) error
type ProcessData ¶
type ProcessData struct { Id string Configuration *pb.ProcessConfiguration }
func (*ProcessData) GetRestartDelay ¶
func (d *ProcessData) GetRestartDelay() time.Duration
func (*ProcessData) GetRestartPolicy ¶
func (d *ProcessData) GetRestartPolicy() *pb.ProcessConfiguration_RestartPolicy
type ProcessExitEvent ¶
type ProcessExitEvent struct { Process *ManagedProcess Exited *process.Process ExitCode int }
type ProcessForceRestartEvent ¶
type ProcessForceRestartEvent struct { Process *ManagedProcess Spawned *process.Process WasRunning bool Error error }
type ProcessList ¶
type ProcessList struct {
// contains filtered or unexported fields
}
ProcessList is a structure that contains a list of processes.
func NewProcessList ¶
func NewProcessList() *ProcessList
func (*ProcessList) All ¶
func (l *ProcessList) All() []*ManagedProcess
All returns a list of all processes. Thread-safe.
func (*ProcessList) Find ¶
func (l *ProcessList) Find(name string) (*ManagedProcess, error)
Find returns the process with given name or pid. If process is not in the registry, returns nil. Thread-safe.
func (*ProcessList) GetById ¶
func (l *ProcessList) GetById(id string) (*ManagedProcess, error)
GetById returns the process with given internal id. If process is not in the registry, returns nil. Thread-safe.
func (*ProcessList) GetByPid ¶
func (l *ProcessList) GetByPid(pid int) (*ManagedProcess, error)
Get returns the process with given pid. If process is not in the registry, returns nil. Thread-safe.
type ProcessSpawnEvent ¶
type ProcessSpawnEvent struct { Process *ManagedProcess Spawned *process.Process Error error }
Click to show internal directories.
Click to hide internal directories.