Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Service defaults. DefaultStartTimeout = 1 * time.Second DefaultStartRetries = 3 DefaultStopSignal = syscall.SIGINT DefaultStopTimeout = 5 * time.Second DefaultStopRestart = true // Service commands. Start = "start" Stop = "stop" Restart = "restart" Shutdown = "shutdown" // Service states. Starting = "starting" Running = "running" Stopping = "stopping" Stopped = "stopped" Exited = "exited" Backoff = "backoff" Fatal = "fatal" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { Service *Service // The service from which the event originated. State string // The new state of the service. Error error // An error indicating why the service is in Exited or Backoff. }
Event is sent by a Service on a state change.
type ExitError ¶
type ExitError string
ExitError indicated why the service entered an Exited or Backoff state.
type Service ¶
type Service struct { Directory string // The process's working directory. Defaults to the current directory. Environment []string // The environment of the process. Defaults to nil which indicates the current environment. StartTimeout time.Duration // How long the process has to run before it's considered Running. StartRetries int // How many times to restart a process if it fails to start. Defaults to 3. StopSignal syscall.Signal // The signal to send when stopping the process. Defaults to SIGINT. StopTimeout time.Duration // How long to wait for a process to stop before sending a SIGKILL. Defaults to 5s. StopRestart bool // Whether or not to restart the process if it exits unexpectedly. Defaults to true. Stdout io.Writer // Where to send the process's stdout. Defaults to /dev/null. Stderr io.Writer // Where to send the process's stderr. Defaults to /dev/null. CommandHook func(*Service, string) error // Function to call before executing a command. Will cancel the command on error. // contains filtered or unexported fields }
Service represents a controllable process. Exported fields may be set to configure the service.
func NewService ¶
New creates a new service with the default configution.
Click to show internal directories.
Click to hide internal directories.