juju: github.com/wallyworld/juju/service/systemd Index | Files | Directories

package systemd

import "github.com/wallyworld/juju/service/systemd"


Package Files

cmdline.go conf.go interface.go serialize.go service.go shims.go


const (
    LibSystemdDir          = "/lib/systemd/system"
    EtcSystemdDir          = "/etc/systemd/system"
    EtcSystemdMultiUserDir = EtcSystemdDir + "/multi-user.target.wants"


var NewDBusAPI = func() (DBusAPI, error) {
    return dbus.New()

func IsRunning Uses

func IsRunning() bool

IsRunning returns whether or not systemd is the local init system.

func ListCommand Uses

func ListCommand() string

ListCommand returns a command that will list the services on a host.

func ListServices Uses

func ListServices() ([]string, error)

ListServices returns the list of installed service names.

func SysdReload Uses

func SysdReload() error

SysdReload reloads Service daemon.

func UnitSerialize Uses

func UnitSerialize(opts []*unit.UnitOption) io.Reader

UnitSerialize encodes all of the given UnitOption objects into a unit file. Renamed from Serialize from github.com/coreos/go-systemd/unit so as to not conflict with the exported internal function in export_test.go.

type Cmdline Uses

type Cmdline struct {
    // contains filtered or unexported fields

Cmdline exposes the core operations of interacting with systemd units.

func (Cmdline) ListAll Uses

func (cl Cmdline) ListAll() ([]string, error)

ListAll returns the names of all enabled systemd units.

type DBusAPI Uses

type DBusAPI interface {
    ListUnits() ([]dbus.UnitStatus, error)
    StartUnit(string, string, chan<- string) (int, error)
    StopUnit(string, string, chan<- string) (int, error)
    LinkUnitFiles([]string, bool, bool) ([]dbus.LinkUnitFileChange, error)
    EnableUnitFiles([]string, bool, bool) (bool, []dbus.EnableUnitFileChange, error)
    DisableUnitFiles([]string, bool) ([]dbus.DisableUnitFileChange, error)
    GetUnitProperties(string) (map[string]interface{}, error)
    GetUnitTypeProperties(string, string) (map[string]interface{}, error)
    Reload() error

DBusAPI describes all the systemd API methods needed by juju.

type DBusAPIFactory Uses

type DBusAPIFactory = func() (DBusAPI, error)

Type alias for a DBusAPI factory method.

type FileSystemOps Uses

type FileSystemOps interface {
    Remove(name string) error
    RemoveAll(name string) error
    WriteFile(fileName string, data []byte, perm os.FileMode) error

FileSystemOps describes file-system operations required to install and remove a service.

type Service Uses

type Service struct {

    ConfName        string
    UnitName        string
    DirName         string
    FallBackDirName string
    Script          []byte
    // contains filtered or unexported fields

Service provides visibility into and control over a systemd service.

func NewService Uses

func NewService(
    name string, conf common.Conf, dataDir string, newDBus DBusAPIFactory, fileOps FileSystemOps, fallBackDirName string,
) (*Service, error)

NewService returns a new reference to an object that implements the Service interface for systemd.

func NewServiceWithDefaults Uses

func NewServiceWithDefaults(name string, conf common.Conf) (*Service, error)

NewServiceWithDefaults returns a new systemd service reference populated with sensible defaults.

func (Service) Conf Uses

func (s Service) Conf() common.Conf

Conf implements service.Service.

func (*Service) Exists Uses

func (s *Service) Exists() (bool, error)

Exists implements Service.

func (*Service) Install Uses

func (s *Service) Install() error

Install implements Service.

func (*Service) InstallCommands Uses

func (s *Service) InstallCommands() ([]string, error)

InstallCommands implements Service.

func (*Service) Installed Uses

func (s *Service) Installed() (bool, error)

Installed implements Service.

func (Service) Name Uses

func (s Service) Name() string

Name implements service.Service.

func (*Service) Remove Uses

func (s *Service) Remove() error

Remove implements Service.

func (*Service) RemoveOldService Uses

func (s *Service) RemoveOldService() error

RemoveOldService (UpgradableService) removes the service files that were written for systemd services prior to 2.7.2. The service definition and any exec-start script used to be written to a directory named after the agent under /lib/systemd/system. A symbolic link then pointed to this local from /etc/systemd/system. We now just write files directly to /etc/systemd/system, so the old directory is deleted if found.

func (*Service) Running Uses

func (s *Service) Running() (bool, error)

Running implements Service.

func (*Service) Start Uses

func (s *Service) Start() error

Start implements Service.

func (*Service) StartCommands Uses

func (s *Service) StartCommands() ([]string, error)

StartCommands implements Service.

func (*Service) Stop Uses

func (s *Service) Stop() error

Stop implements Service.

func (*Service) WriteService Uses

func (s *Service) WriteService() error

WriteService (UpgradableService) writes a systemd unit file for the service and ensures that it is linked and enabled by systemd.

type ShimExec Uses

type ShimExec interface {
    RunCommands(args exec.RunParams) (*exec.ExecResponse, error)

ShimExec is used to indirect command-line interactions. A mock for this is "patched" over the the listed methods by the test suite. This should be phased out in favour of the fileSystemOps approach below.



Package systemd imports 19 packages (graph). Updated 2020-08-06. Refresh now. Tools for package owners.