Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct { // Path is the path to the program's executable Path string // Args are the arguments passed to the program's executable. Args []string // Workdir specifies the working directory for the program. Workdir string // Env specifies the environment for the program. Env []string // StopSignal specifies the signal used to stop the program, when Stop is called on the handle returned by // a call to Start. If it's empty when Start is called, SIGTERM is used. StopSignal syscall.Signal // GracePeriod specifies the max time to wait for the program to quit on its own before it is // killed after a call to Stop on the handle returned by the call to Start. GracePeriod time.Duration }
Command represents the command to start a Service. All fields can be changed at any time and will have effect on next call to Start.
type Handle ¶
type Handle interface { // Wait blocks until the service stopped (either because it decided to stop on its own, or because Stop was called). Wait() error // Stop stops the service. Stop() }
Handle represents a running Service.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func (*Manager) Shutdown ¶
func (mgr *Manager) Shutdown()
Shutdown initiate stopping all running services, blocking until all have stopped. Further calls return immediately. Once Shutdown returns, the Manager can't be used anymore to Start or Stop services.
func (*Manager) Start ¶
Start starts the Services if they are not running. It does nothing if called after shutdown was initiate by a call to Shutdown.
func (*Manager) Stop ¶
Stop stops one or more services. Has no effect when called after Shutdown, as all running services will be in the process of stopping or already stopped.
func (*Manager) Subscribe ¶
Subscribe returns a new channel to which a Change is written every time a service starts and stops, and it's closed when ctx is canceled or the Manager shutdowns. There might still be Changes to read after subscription is canceled. If Subscribe is called after shutdown a closed channel is returned.
type Service ¶
type Service interface { // Start starts the service, and returns an Handle to represent the running Service, or a nil Handle and an error // if the service cannot be started. Calling Start multiple times should start multiple instances of the Service. Start() (Handle, error) Name() string fmt.Stringer }