upstart

package
v0.0.0-...-ef0d7b0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IllegalBindToError                  = errors.New("upstart/config.BaseConfig: Illegal nil value received for `bindTo'")
	InvalidFlagsInstallUninstallError   = errors.New("-install flag must not be accompanied by -uninstall flag")
	InvalidFlagsMissingServiceUserError = errors.New(`-user flag must be specified if -install flag is set`)
)
View Source
var (
	MustRunAsRootToInstall = errors.New("must be run as root to install system service")
	UnsupportedOsError     = errors.New("unsupported operating system (must be ubuntu)")
)

Functions

func BaseFlagSet

func BaseFlagSet(name string) *flag.FlagSet

BaseFlagSet provides a *flag.FlagSet which corresponds with BaseConfig. Extend with additional flags to suit needs.

func FunctionName

func FunctionName(i interface{}) string

func InstallService

func InstallService(config UpstartConfig) error

func PathExists

func PathExists(path string) (bool, error)

PathExists returns whether or not the given file or directory exists.

func UninstallService

func UninstallService(config UpstartConfig) error

Types

type ErrorProducer

type ErrorProducer func(config UpstartConfig) error // Installation steps are each [possible] error producers.

type FlagsConfig

type FlagsConfig struct {
	Install     bool   `flag:"install"`
	CustomPipe  string `flag:"install-with-custom-pipe"`
	Uninstall   bool   `flag:"uninstall"`
	ServiceUser string `flag:"user"`
	ServiceArgs string // Automatically populated within `Validate()'; used for installing system service.
	// contains filtered or unexported fields
}

FlagsConfig is a common representation of the fundamental set of options for upstart service management. Intended to help reduce repetitive command-line flags handling.

NB: A flag for "config" is also used, even though it is not defined as a field in FlagsConfig.

NB: This uses github.com/BurntSushi/toml and github.com/mreiferson/go-options packages for flag management.

func NewFlagsConfig

func NewFlagsConfig(flagSet *flag.FlagSet, args []string) *FlagsConfig

New creates and returns a new instance of FlagsConfig.

NB: In the common case the value of `args' should be `os.Args[1:]'.

func (*FlagsConfig) Args

func (config *FlagsConfig) Args() []string

func (*FlagsConfig) ConfigMap

func (config *FlagsConfig) ConfigMap() map[string]interface{}

func (*FlagsConfig) FlagSet

func (config *FlagsConfig) FlagSet() *flag.FlagSet

func (*FlagsConfig) InstallService

func (config *FlagsConfig) InstallService(serviceName string) error

func (*FlagsConfig) UninstallService

func (config *FlagsConfig) UninstallService(serviceName string) error

func (*FlagsConfig) Validate

func (config *FlagsConfig) Validate(bindTo interface{}) error

Validate takes a `bindTo' parameter which *MUST* be a pointer to the topmost Config struct instance (assuming FlagsConfig contained as an embedded type). This ensures that the flag bindings get applied to all fields.

If you override the Validate method, don't forget to invoke base validation.

Example usage:

myConfig.Validate(myConfig)

or

myConfig.FlagsConfig.Validate(myConfig).

type UpstartConfig

type UpstartConfig struct {
	ServiceName         string
	Args                string
	PipedCommand        string
	InstallBinPath      string
	UpstartConfFilePath string // e.g. /etc/init/{{ServiceName}}.
	InitSymlinkPath     string // e.g. /etc/init.d/{{ServiceName}}, required for service-name tab auto-complete to work.
	User                string
}

func DefaultConfig

func DefaultConfig(serviceName string) UpstartConfig

func (UpstartConfig) ServiceBinPath

func (config UpstartConfig) ServiceBinPath() string

Jump to

Keyboard shortcuts

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