supervisor

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoggerProvider

type LoggerProvider interface {
	GetLogger(serviceName string) io.Writer
}

LoggerProvider is an interface for providing loggers for services

type ServiceInfo

type ServiceInfo struct {
	Name         string
	Status       ServiceStatus
	Pid          int
	Uptime       time.Duration
	StartTime    time.Time
	RestartCount int
	NextRestart  time.Time
	NextRun      time.Time
	ExitCode     int
	Error        string
	Cmd          *exec.Cmd
	Process      *os.Process
	Config       config.Process
	// Resource usage
	CpuPercent  float64
	MemoryUsage int64
	LastUpdated time.Time
	// Flag to indicate if the service was explicitly stopped
	ExplicitlyStopped bool
}

ServiceInfo represents information about a service

type ServiceStatus

type ServiceStatus string

ServiceStatus represents the status of a service

const (
	StatusStopped    ServiceStatus = "stopped"
	StatusRunning    ServiceStatus = "running"
	StatusFailed     ServiceStatus = "failed"
	StatusRestarting ServiceStatus = "restarting"
	StatusScheduled  ServiceStatus = "scheduled"
)

type Supervisor

type Supervisor struct {
	// contains filtered or unexported fields
}

Supervisor manages the lifecycle of services

func NewSupervisor

func NewSupervisor(cfg *config.Config, activeServices map[string]bool, verbose bool) *Supervisor

NewSupervisor creates a new supervisor

func (*Supervisor) DisableCronJob

func (s *Supervisor) DisableCronJob(name string) error

DisableCronJob disables a cron job

func (*Supervisor) EnableCronJob

func (s *Supervisor) EnableCronJob(name string) error

EnableCronJob enables a cron job

func (*Supervisor) GetAllServiceStatuses

func (s *Supervisor) GetAllServiceStatuses() map[string]*ServiceInfo

GetAllServiceStatuses returns the status of all services

func (*Supervisor) GetServiceStatus

func (s *Supervisor) GetServiceStatus(name string) (*ServiceInfo, error)

GetServiceStatus returns the status of a service

func (*Supervisor) RestartService

func (s *Supervisor) RestartService(name string) error

RestartService restarts a service

func (*Supervisor) SetLoggerProvider

func (s *Supervisor) SetLoggerProvider(provider LoggerProvider)

SetLoggerProvider sets the logger provider for the supervisor

func (*Supervisor) Start

func (s *Supervisor) Start() error

Start starts the supervisor

func (*Supervisor) StartService

func (s *Supervisor) StartService(name string) error

StartService starts a service

func (*Supervisor) Stop

func (s *Supervisor) Stop()

Stop stops the supervisor

func (*Supervisor) StopService

func (s *Supervisor) StopService(name string) error

StopService stops a service

Jump to

Keyboard shortcuts

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