Documentation ¶
Index ¶
- Constants
- Variables
- func Supported(filename string) bool
- func SupportedSuffix(suffix string) bool
- type Daemon
- func (sys *Daemon) Disable(names ...string) (err error)
- func (sys *Daemon) Enable(names ...string) (err error)
- func (sys *Daemon) Get(name string) (u *Unit, err error)
- func (sys *Daemon) IsActive(name string) (st unit.Activation, err error)
- func (sys *Daemon) IsEnabled(name string) (st unit.Enable, err error)
- func (sys *Daemon) Isolate(names ...string) (err error)
- func (sys *Daemon) Paths() (paths []string)
- func (sys *Daemon) Reload(names ...string) (err error)
- func (sys *Daemon) Restart(names ...string) (err error)
- func (sys *Daemon) SetPaths(paths ...string)
- func (sys *Daemon) Since() (t time.Time)
- func (sys *Daemon) Start(names ...string) (err error)
- func (sys *Daemon) Status() (st Status, err error)
- func (sys *Daemon) StatusOf(name string) (st unit.Status, err error)
- func (sys *Daemon) Stop(names ...string) (err error)
- func (sys *Daemon) Supervise(name string, v unit.Interface) (u *Unit, err error)
- func (sys *Daemon) Unit(name string) (u *Unit, err error)
- func (sys *Daemon) Units() (units []*Unit)
- type Log
- type State
- type Status
- type Target
- type Unit
- func (u *Unit) Active() (st unit.Activation)
- func (u *Unit) Disable() (err error)
- func (u *Unit) Enable() (err error)
- func (u *Unit) IsActivating() bool
- func (u *Unit) IsActive() bool
- func (u *Unit) IsDeactivating() bool
- func (u *Unit) IsDead() bool
- func (u *Unit) IsLoaded() bool
- func (u *Unit) IsReloader() (ok bool)
- func (u *Unit) IsReloading() bool
- func (u *Unit) Loaded() unit.Load
- func (u *Unit) Name() string
- func (u *Unit) Path() string
- func (u *Unit) Reload() (err error)
- func (u *Unit) Requires() (names []string)
- func (u *Unit) Start() (err error)
- func (u *Unit) Status() unit.Status
- func (u *Unit) Stop() (err error)
- func (u *Unit) Sub() string
- func (u *Unit) Wants() (names []string)
Constants ¶
const BUFFER_SIZE = 10000
Maximum number of bytes kept if log buffer
Variables ¶
var DEFAULT_PATHS = []string{"/etc/systemd/system/", "/run/systemd/system", "/lib/systemd/system"}
Default paths to search for unit paths - Daemon uses those, if none are specified
var ErrDepConflict = errors.New("Error stopping conflicting unit")
var ErrDepFail = errors.New("Dependency failed to start. See unit log for details.")
var ErrExists = errors.New("Unit already exists")
var ErrIsDir = errors.New("Is a directory")
var ErrIsStarting = errors.New("Unit is already starting")
var ErrNoReload = errors.New("Unit does not support reloading")
var ErrNotActive = errors.New("Unit is not active")
var ErrNotDir = errors.New("Is not a directory")
var ErrNotFound = errors.New("Not found")
var ErrNotImplemented = errors.New("Not implemented yet")
var ErrNotLoaded = errors.New("Unit is not loaded.")
var ErrUnknownType = errors.New("Unknown type")
var ErrUnmergeable = errors.New("Unmergeable job types")
Functions ¶
func Supported ¶
Supported returns a bool indicating if filename represents a unit type, which is supported by Systemgo
func SupportedSuffix ¶
SupportedSuffix returns a bool indicating if suffix represents a unit type, which is supported by Systemgo
Types ¶
type Daemon ¶
type Daemon struct { // System log Log *Log // contains filtered or unexported fields }
Daemon supervises instances of Unit
func (*Daemon) Disable ¶
Disable gets names from internal hasmap and calls Disable() on each unit returned
func (*Daemon) Enable ¶
Enable gets names from internal hasmap and calls Enable() on each unit returned
func (*Daemon) Get ¶
Get looks up the unit name in the internal hasmap of loaded units and calls sys.Load(name) if it can not be found. If error is returned, it will be error from sys.Load(name)
func (*Daemon) IsActive ¶
func (sys *Daemon) IsActive(name string) (st unit.Activation, err error)
IsActive returns activation state of the unit held in-memory under specified name. If error is returned, it is going to be ErrNotFound
func (*Daemon) IsEnabled ¶
IsEnabled returns enable state of the unit held in-memory under specified name. If error is returned, it is going to be ErrNotFound
TODO
func (*Daemon) Isolate ¶
Isolate gets names from internal hashmap, creates a new start transaction, adds a stop job for each unit currently active, but not in the transaction already and runs the transaction
func (*Daemon) Paths ¶
Paths returns paths, which get searched for unit files by sys(first path gets searched first)
func (*Daemon) Reload ¶
Reload gets names from internal hashmap, creates a new reload transaction and runs it
func (*Daemon) Restart ¶
Restart gets names from internal hashmap, creates a new restart transaction and runs it
func (*Daemon) SetPaths ¶
SetPaths sets paths, which get searched for unit files by sys(first path gets searched first)
func (*Daemon) Start ¶
Start gets names from internal hashmap, creates a new start transaction and runs it
func (*Daemon) Status ¶
Status returns status of the system If error is returned it is going to be an error, returned by the call to ioutil.ReadAll(sys.Log)
func (*Daemon) StatusOf ¶
StatusOf returns status of the unit held in-memory under specified name. If error is returned, it is going to be ErrNotFound
func (*Daemon) Stop ¶
Stop gets names from internal hashmap, creates a new stop transaction and runs it
func (*Daemon) Supervise ¶
Supervise creates a *Unit wrapping v and stores it in internal hashmap. If a unit with name specified already exists - nil and ErrExists are returned
type Log ¶
Log uses log.Logger to write data to embedded bytes.Buffer Keeps up to 10000 bytes of data in-memory
type Status ¶
type Status struct { // State of the system State State `json:"State,string"` // Number of queued jobs in-total Jobs int `json:"Jobs"` // Number of failed units Failed int `json:"Failed"` // Init time Since time.Time `json:"Since"` // Log Log []byte `json:"Log, omitempty"` }
System status
type Target ¶
type Target struct { unit.Definition System *Daemon }
Target unit type is used for grouping units
func (*Target) Active ¶
func (targ *Target) Active() unit.Activation
Active returns activation status of the unit
type Unit ¶
type Unit struct { unit.Interface // System the Unit came from System *Daemon // Unit log Log *Log // contains filtered or unexported fields }
func (*Unit) Active ¶
func (u *Unit) Active() (st unit.Activation)
func (*Unit) Enable ¶
Enable creates symlinks to u definition in dependency directories of each unit dependant on u
func (*Unit) IsActivating ¶
func (*Unit) IsDeactivating ¶
func (*Unit) IsReloader ¶
IsReloader returns whether u.Interface is capable of reloading
func (*Unit) IsReloading ¶
func (*Unit) Requires ¶
Requires returns a slice of unit names as found in definition and absolute paths of units symlinked in units '.wants' directory