services

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2014 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

runit manages services usually found in /etc/service or /service, which are soft links to the actual service directories in /etc/sv:

<service_name>/
    run
    log/
       run
    supervise/
       pid  # => 4994
       stat # => run / down

Index

Constants

View Source
const (
	Unknown  Status = "Unknown"
	Down            = "Down"
	Starting        = "Starting"
	Up              = "Up"
)

Variables

View Source
var ErrServiceNotFound = errors.New("No such service")
View Source
var (
	SupportedInits = []func() (InitSystem, error){
		func() (InitSystem, error) {
			return detectLaunchd("/")
		},
		func() (InitSystem, error) {
			return detectUpstart("/etc/init")
		},
		func() (InitSystem, error) {
			return detectRunit("/")
		},
		func() (InitSystem, error) {
			return detectSystemd("/etc/systemd")
		},
	}
)

Functions

This section is empty.

Types

type InitSystem

type InitSystem interface {
	// Name of the init system: "upstart", "runit", etc.
	Name() string

	// Find the process info for a given service name.  All errors
	// returned must be of type ServiceError.
	LookupService(name string) (*ProcessStatus, error)

	// Restart the process associated with the given service name.  All errors
	// returned must be of type ServiceError.
	Restart(name string) error
}

Your init system(s) manages services. We use the init system to: 1. find the associated process 2. restart the service

func Detect

func Detect() []InitSystem

type Launchd

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

func (*Launchd) LookupService

func (l *Launchd) LookupService(serviceName string) (*ProcessStatus, error)

func (*Launchd) Name

func (l *Launchd) Name() string

func (*Launchd) Restart

func (l *Launchd) Restart(serviceName string) error

type MockInitSystem

type MockInitSystem struct {
	Actions       []string
	CurrentStatus *ProcessStatus
}

func MockInit

func MockInit() *MockInitSystem

func (*MockInitSystem) LookupService

func (m *MockInitSystem) LookupService(name string) (*ProcessStatus, error)

func (*MockInitSystem) Name

func (m *MockInitSystem) Name() string

func (*MockInitSystem) Restart

func (m *MockInitSystem) Restart(name string) error

type ProcessStatus

type ProcessStatus struct {
	Pid int
	Status
}

func NewStatus

func NewStatus() *ProcessStatus

func (*ProcessStatus) String

func (s *ProcessStatus) String() string

type Runit

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

func (*Runit) LookupService

func (r *Runit) LookupService(serviceName string) (*ProcessStatus, error)

func (*Runit) Name

func (r *Runit) Name() string

func (*Runit) Restart

func (r *Runit) Restart(serviceName string) error

type ServiceError

type ServiceError struct {
	Init string
	Name string
	Err  error
}

func (*ServiceError) Error

func (e *ServiceError) Error() string

type Status

type Status string

func (Status) String

func (s Status) String() string

type Systemd

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

func (*Systemd) LookupService

func (u *Systemd) LookupService(serviceName string) (*ProcessStatus, error)

func (*Systemd) Name

func (u *Systemd) Name() string

func (*Systemd) Restart

func (u *Systemd) Restart(serviceName string) error

type Upstart

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

func (*Upstart) LookupService

func (u *Upstart) LookupService(serviceName string) (*ProcessStatus, error)

func (*Upstart) Name

func (u *Upstart) Name() string

func (*Upstart) Restart

func (u *Upstart) Restart(serviceName string) error

Jump to

Keyboard shortcuts

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