ctinit

package
v0.0.0-...-77ffcd7 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLineBufferSize = 16384
View Source
const DefaultStreamChanSize = 1000

Variables

This section is empty.

Functions

This section is empty.

Types

type Daemon

type Daemon struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDaemon

func NewDaemon(options ...DaemonOption) *Daemon

func (*Daemon) Add

func (daemon *Daemon) Add(name string, binary string, args ...interface{}) (*Service, error)

func (*Daemon) IsRunning

func (daemon *Daemon) IsRunning() bool

func (*Daemon) IsStopping

func (daemon *Daemon) IsStopping() bool

func (*Daemon) Remove

func (daemon *Daemon) Remove(name string) error

func (*Daemon) Signal

func (daemon *Daemon) Signal(name string, sig syscall.Signal) error

func (*Daemon) SignalAll

func (daemon *Daemon) SignalAll(sig syscall.Signal)

func (*Daemon) Status

func (daemon *Daemon) Status(name string) *ServiceJSON

func (*Daemon) Stop

func (daemon *Daemon) Stop(name string) error

func (*Daemon) StopAll

func (daemon *Daemon) StopAll(kill bool)

func (*Daemon) Supervise

func (daemon *Daemon) Supervise() error

func (*Daemon) Unwatch

func (daemon *Daemon) Unwatch(watcherCh chan *ServiceJSON)

func (*Daemon) Watch

func (daemon *Daemon) Watch(watcherCh chan *ServiceJSON)

type DaemonOption

type DaemonOption func(daemon *Daemon)

func Logger

func Logger(logger *log.Logger) DaemonOption

func StopOnFailure

func StopOnFailure() DaemonOption

type ErrLineBufferOverflow

type ErrLineBufferOverflow struct {
	Line       string
	BufferSize int
	BufferFree int
}

func (ErrLineBufferOverflow) Error

func (err ErrLineBufferOverflow) Error() string

type OutputStream

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

func NewOutputStream

func NewOutputStream(streamCh chan string) *OutputStream

func (*OutputStream) Lines

func (os *OutputStream) Lines() <-chan string

func (*OutputStream) SetLineBufferSize

func (os *OutputStream) SetLineBufferSize(n int)

func (*OutputStream) Write

func (os *OutputStream) Write(p []byte) (n int, err error)

type Service

type Service struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewService

func NewService(binary string, args []string, options ...ServiceOption) *Service

func (*Service) Clone

func (svc *Service) Clone(keepState bool) *Service

func (*Service) Done

func (svc *Service) Done() <-chan struct{}

func (*Service) HasFinalState

func (svc *Service) HasFinalState() bool

func (*Service) HasInitialState

func (svc *Service) HasInitialState() bool

func (*Service) HasRunningState

func (svc *Service) HasRunningState() bool

func (*Service) Signal

func (svc *Service) Signal(sig syscall.Signal) error

func (*Service) Start

func (svc *Service) Start() <-chan ServiceStatus

func (*Service) Status

func (svc *Service) Status() ServiceStatus

func (*Service) Stop

func (svc *Service) Stop() error

type ServiceJSON

type ServiceJSON struct {
	Name       string `json:"name"`
	Command    string `json:"command"`
	State      string `json:"state"`
	PID        int    `json:"pid"`
	ExitCode   int    `json:"exitCode"`
	Error      error  `json:"error"`
	RetryCount uint   `json:"retryCount"`
	RetryLimit uint   `json:"retryLimit"`

	IsCompleted bool `json:"isCompleted"`
}

type ServiceOption

type ServiceOption func(svc *Service)

func Retries

func Retries(times uint) ServiceOption

func StartDelay

func StartDelay(delay time.Duration) ServiceOption

type ServiceStatus

type ServiceStatus struct {
	PID      int
	ExitCode int
	Error    error
}

type State

type State uint8
const (
	INITIAL State = iota
	IDLE
	STARTING
	RUNNING
	STOPPING
	INTERRUPT
	FINISHED
	FATAL
)

func (State) String

func (state State) String() string

Jump to

Keyboard shortcuts

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