launchd

package
v1.0.44 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Rendered for darwin/amd64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install(plist Plist, wait time.Duration, log Log) error

Install will install a service

func PlistDestination

func PlistDestination(label string) string

PlistDestination is the plist path for a label

func Restart

func Restart(label string, wait time.Duration, log Log) error

Restart restarts a service

func ShowStatus

func ShowStatus(label string, log Log) error

ShowStatus shows status info for a service

func Start

func Start(label string, wait time.Duration, log Log) error

Start will start a service

func Stop

func Stop(label string, wait time.Duration, log Log) (bool, error)

Stop a service. Returns true, nil on successful stop. If false, nil is returned it means there was nothing to stop.

func Uninstall

func Uninstall(label string, wait time.Duration, log Log) error

Uninstall will uninstall a service

Types

type EnvVar

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

EnvVar defines and environment variable for the Plist

func NewEnvVar

func NewEnvVar(key string, value string) EnvVar

NewEnvVar creates a new environment variable

type Log added in v1.0.17

type Log interface {
	Debug(s string, args ...interface{})
	Info(s string, args ...interface{})
	Errorf(s string, args ...interface{})
}

Log is the logging interface for this package

type Plist

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

Plist defines a launchd plist

func NewPlist

func NewPlist(label string, binPath string, args []string, envVars []EnvVar, logPath string, comment string) Plist

NewPlist constructs a launchd service plist

func (Plist) Check

func (p Plist) Check(path string) (bool, error)

Check if plist matches plist at path

func (Plist) Env added in v1.0.34

func (p Plist) Env() []string

func (Plist) FallbackCommand added in v1.0.34

func (p Plist) FallbackCommand() *exec.Cmd

type Service

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

Service defines a service

func ListServices

func ListServices(filters []string) (services []Service, err error)

ListServices will return service with label that starts with a filter string.

func NewService

func NewService(label string) Service

NewService constructs a launchd service.

func (Service) CheckPlist

func (s Service) CheckPlist(plist Plist) (bool, error)

CheckPlist returns false, if the plist destination doesn't match what we would install. This means the plist is old and we need to update it.

func (Service) HasPlist

func (s Service) HasPlist() bool

HasPlist returns true if service has plist installed

func (Service) Install

func (s Service) Install(p Plist, wait time.Duration) error

Install will install the launchd service

func (Service) Label

func (s Service) Label() string

Label for service

func (Service) LoadStatus

func (s Service) LoadStatus() (*ServiceStatus, error)

LoadStatus returns service status

func (Service) PlistDestination

func (s Service) PlistDestination() string

PlistDestination is the service plist path

func (Service) Restart

func (s Service) Restart(wait time.Duration) error

Restart a service.

func (*Service) SetLogger

func (s *Service) SetLogger(log Log)

SetLogger sets the logger

func (Service) Start

func (s Service) Start(wait time.Duration) error

Start will start the service.

func (Service) StatusDescription

func (s Service) StatusDescription() string

StatusDescription returns the service status description

func (Service) Stop

func (s Service) Stop(wait time.Duration) (bool, error)

Stop a service. Returns true, nil on successful stop. If false, nil is returned it means there was nothing to stop.

func (Service) Uninstall

func (s Service) Uninstall(wait time.Duration) error

Uninstall will uninstall the launchd service

func (Service) WaitForExit

func (s Service) WaitForExit(wait time.Duration) error

WaitForExit waits for service to exit

func (Service) WaitForStatus added in v1.0.16

func (s Service) WaitForStatus(wait time.Duration, delay time.Duration) (*ServiceStatus, error)

WaitForStatus waits for service status to be available

type ServiceStatus

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

ServiceStatus defines status for a service

func (ServiceStatus) Description

func (s ServiceStatus) Description() string

Description returns service status info

func (ServiceStatus) HasRun added in v1.0.17

func (s ServiceStatus) HasRun() bool

HasRun returns true if service is running, or has run and failed

func (ServiceStatus) IsErrored added in v1.0.17

func (s ServiceStatus) IsErrored() bool

IsErrored is true if the service errored trying to start

func (ServiceStatus) IsRunning

func (s ServiceStatus) IsRunning() bool

IsRunning is true if the service is running (with a pid)

func (ServiceStatus) Label

func (s ServiceStatus) Label() string

Label for status

func (ServiceStatus) LastExitStatus

func (s ServiceStatus) LastExitStatus() string

LastExitStatus will be blank if pid > 0, or a number "123"

func (ServiceStatus) Pid

func (s ServiceStatus) Pid() string

Pid for status (empty string if not running)

Jump to

Keyboard shortcuts

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