Documentation ¶
Overview ¶
Package zinit exposes function to interat with zinit service life cyle management
Index ¶
- Constants
- Variables
- func AddService(name string, service InitService) error
- func RemoveService(name string) error
- type Client
- func (c *Client) Close() error
- func (c *Client) Forget(service string) error
- func (c *Client) Kill(service string, sig Signal) error
- func (c *Client) List() (map[string]ServiceState, error)
- func (c *Client) Monitor(service string) error
- func (c *Client) Start(service string) error
- func (c *Client) StartWait(timeout time.Duration, service string) error
- func (c *Client) Status(service string) (ServiceStatus, error)
- func (c *Client) Stop(service string) error
- func (c *Client) StopWait(timeout time.Duration, service string) error
- type InitService
- type LogType
- type PossibleState
- type ServiceState
- type ServiceStatus
- type ServiceTarget
- type Signal
Constants ¶
const ( // ServiceStateUnknown is return when we cannot determine the status of a service ServiceStateUnknown PossibleState = "unknown" // ServiceStateRunning is return when we a service process is running and healthy ServiceStateRunning = "running" // ServiceStateBlocked is returned if the service can't start because of an unsatisfied dependency ServiceStateBlocked = "blocked" // ServiceStateSpawned service has started, but zinit is not sure about its status yet. // this is usually a short-lived status, unless a test command is provided. In that case // the spawned state will only go to success if the test pass ServiceStateSpawned = "spawned" // ServiceStateSuccess is return when a one shot service exited without errors ServiceStateSuccess = "success" // ServiceStateError is return when we a service exit with an error (exit code != 0) ServiceStateError = "error" //ServiceStateFailure is set of zinit can not spawn a service in the first place //due to a missing executable for example. Unlike `error` which is returned if the //service itself exits with an error. ServiceStateFailure = "failure" )
Variables ¶
var ( SIGABRT = Signal("SIGABRT") SIGALRM = Signal("SIGALRM") SIGBUS = Signal("SIGBUS") SIGCHLD = Signal("SIGCHLD") SIGCLD = Signal("SIGCLD") SIGCONT = Signal("SIGCONT") SIGFPE = Signal("SIGFPE") SIGHUP = Signal("SIGHUP") SIGILL = Signal("SIGILL") SIGINT = Signal("SIGINT") SIGIO = Signal("SIGIO") SIGIOT = Signal("SIGIOT") SIGKILL = Signal("SIGKILL") SIGPIPE = Signal("SIGPIPE") SIGPOLL = Signal("SIGPOLL") SIGPROF = Signal("SIGPROF") SIGPWR = Signal("SIGPWR") SIGQUIT = Signal("SIGQUIT") SIGSEGV = Signal("SIGSEGV") SIGSTKFLT = Signal("SIGSTKFLT") SIGSTOP = Signal("SIGSTOP") SIGSYS = Signal("SIGSYS") SIGTERM = Signal("SIGTERM") SIGTRAP = Signal("SIGTRAP") SIGTSTP = Signal("SIGTSTP") SIGTTIN = Signal("SIGTTIN") SIGTTOU = Signal("SIGTTOU") SIGUNUSED = Signal("SIGUNUSED") SIGURG = Signal("SIGURG") SIGUSR1 = Signal("SIGUSR1") SIGUSR2 = Signal("SIGUSR2") SIGVTALRM = Signal("SIGVTALRM") SIGWINCH = Signal("SIGWINCH") SIGXCPU = Signal("SIGXCPU") SIGXFSZ = Signal("SIGXFSZ") )
List of supported signal
Functions ¶
func AddService ¶
func AddService(name string, service InitService) error
AddService write the service into a file in the expected location for Zinit you usually want to call Monitor(name) after adding a service
func RemoveService ¶
RemoveService delete the service file from the filesystem make sure the service has been stopped and forgot before deleting it
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for zinit action it talks to zinit directly over its unis socket
func (*Client) Kill ¶
Kill sends a signal to a running service. sig must be a valid signal (SIGINT, SIGKILL,...)
func (*Client) List ¶
func (c *Client) List() (map[string]ServiceState, error)
List returns all the service monitored and their status
func (*Client) StartWait ¶
StartWait starts a service and wait until its running, or until the timeout (seconds) pass. If timedout, the method returns an error if the service is not running timout of 0 means no wait. (similar to Stop) timout is a min of 1 second
func (*Client) Status ¶
func (c *Client) Status(service string) (ServiceStatus, error)
Status returns the status of a service
type InitService ¶
type InitService struct { Exec string `yaml:"exec,omitempty"` Oneshot bool `yaml:"oneshot,omitempty"` Test string `yaml:"test,omitempty"` After []string `yaml:"after,omitempty"` Log LogType `yaml:"log,omitempty"` }
InitService represent a Zinit service file
type LogType ¶
type LogType string
LogType is an enum type
All the type of logging supported by zinit
func (*LogType) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface
type PossibleState ¶
type PossibleState string
PossibleState represents the state of a service managed by zinit
type ServiceState ¶
type ServiceState struct {
// contains filtered or unexported fields
}
ServiceState describes the service state
func (*ServiceState) Exited ¶
func (s *ServiceState) Exited() bool
Exited is true if the service state in a (stopped) state
func (*ServiceState) Is ¶
func (s *ServiceState) Is(state PossibleState) bool
Is checks if service state is equal to a possible state
func (*ServiceState) MarshalYAML ¶
func (s *ServiceState) MarshalYAML() (interface{}, error)
MarshalYAML implements the yaml.Unmarshaler interface
func (*ServiceState) String ¶
func (s *ServiceState) String() string
func (*ServiceState) UnmarshalYAML ¶
func (s *ServiceState) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface
type ServiceStatus ¶
type ServiceStatus struct { Name string Pid int State ServiceState Target ServiceTarget // Deps is the list of dependent services // all dependencies needs to be running before a service // can starts Deps map[string]string }
ServiceStatus represent the status of a service
type ServiceTarget ¶
type ServiceTarget string
ServiceTarget represents the desired state of a service
const ( // ServiceTargetUp means the service has been asked to start ServiceTargetUp ServiceTarget = "up" // ServiceTargetDown means the service has been asked to stop ServiceTargetDown = "down" )
func (*ServiceTarget) UnmarshalYAML ¶
func (s *ServiceTarget) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface