linuxservicecmd

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SystemdSystemPath = "/etc/systemd/system/"
)

Variables

This section is empty.

Functions

func DisableMultipleServices

func DisableMultipleServices(
	isDetailedError,
	isContinueOnErr bool,
	errCollection *errwrappers.Collection,
	servicesNames []string,
) (isSuccess bool)

func EnableMultipleServices

func EnableMultipleServices(
	isDetailedError,
	isContinueOnErr bool,
	errCollection *errwrappers.Collection,
	servicesNames ...string,
) (isSuccess bool)

func GetStatus

func GetStatus(serviceName string) linuxservicestate.ExitCode

func IsNamePathExist added in v0.8.9

func IsNamePathExist(name string) bool

IsNamePathExist

Refers to environment, binary, or look path for the given name.

func IsRunning

func IsRunning(serviceName string) bool

func IsServiceExist

func IsServiceExist(serviceName string) bool

func IsUnknownServiceExist

func IsUnknownServiceExist(serviceName string) bool

func ReloadMultipleServices

func ReloadMultipleServices(
	isDetailedError,
	isContinueOnErr bool,
	errCollection *errwrappers.Collection,
	servicesNames ...string,
) (isSuccess bool)

func ReloadQuick added in v0.8.9

func ReloadQuick(
	servicesName string,
) *errorwrapper.Wrapper

func RestartMultipleServices

func RestartMultipleServices(
	isDetailedError,
	isContinueOnErr bool,
	errCollection *errwrappers.Collection,
	servicesNames ...string,
) (isSuccess bool)

func RestartQuick added in v0.8.9

func RestartQuick(
	servicesName string,
) *errorwrapper.Wrapper

func RunServices

func RunServices(
	isDetailedError,
	isContinueOnErr bool,
	isIgnoreUnknownService bool,
	errCollection *errwrappers.Collection,
	action servicestate.Action,
	servicesNames ...string,
) (isSuccess bool)

func SimpleVerifyStatus

func SimpleVerifyStatus(serviceName string) *errorwrapper.Wrapper

func StartMultipleServices

func StartMultipleServices(
	isDetailedError,
	isContinueOnErr bool,
	errCollection *errwrappers.Collection,
	servicesNames ...string,
) (isSuccess bool)

func StartQuick added in v0.8.9

func StartQuick(
	servicesName string,
) *errorwrapper.Wrapper

func StopMultipleServices

func StopMultipleServices(
	isDetailedError,
	isContinueOnErr bool,
	errCollection *errwrappers.Collection,
	servicesNames ...string,
) (isSuccess bool)

func StopQuick added in v0.8.9

func StopQuick(
	servicesName string,
) *errorwrapper.Wrapper

func StopStartMultipleServices

func StopStartMultipleServices(
	isDetailedError,
	isContinueOnErr bool,
	errCollection *errwrappers.Collection,
	sleep time.Duration,
	servicesNames ...string,
) (isSuccess bool)

func VerifyExitCode

func VerifyExitCode(
	serviceName string,
	expectedExitCode linuxservicestate.ExitCode,
) *errorwrapper.Wrapper

Types

type CoreServicesInstruction

type CoreServicesInstruction struct {
	IsIgnoreUnknownService bool                `json:"IsIgnoreUnknownService,omitempty"`
	Action                 servicestate.Action `json:"Action"`
	ServicesNames          []string            `json:"ServicesNames,omitempty"`
}

type ManyServicesInstruction

type ManyServicesInstruction struct {
	IsDetailedError   bool `json:"IsDetailedError,omitempty"`
	IsContinueOnError bool `json:"IsContinueOnError,omitempty"`
	CoreServicesInstruction
}

func (*ManyServicesInstruction) Apply

func (it *ManyServicesInstruction) Apply(errCollection *errwrappers.Collection) (isSuccess bool)

func (*ManyServicesInstruction) IsEmpty

func (it *ManyServicesInstruction) IsEmpty() bool

func (*ManyServicesInstruction) Results

func (it *ManyServicesInstruction) Results(errCollection *errwrappers.Collection) *Results

func (*ManyServicesInstruction) Status

func (it *ManyServicesInstruction) Status(errCollection *errwrappers.Collection) (isSuccess bool)

type ManyServicesInstructions

type ManyServicesInstructions struct {
	IsDetailedError   bool                      `json:"IsDetailedError,omitempty"`
	IsContinueOnError bool                      `json:"IsContinueOnError,omitempty"`
	Instructions      []CoreServicesInstruction `json:"Instructions,omitempty"`
}

func (*ManyServicesInstructions) Apply

func (it *ManyServicesInstructions) Apply(
	errCollection *errwrappers.Collection,
) (isSuccess bool)

func (*ManyServicesInstructions) IsEmpty

func (it *ManyServicesInstructions) IsEmpty() bool

func (*ManyServicesInstructions) Run

func (it *ManyServicesInstructions) Run(
	errCollection *errwrappers.Collection,
	action servicestate.Action,
) (isSuccess bool)

func (*ManyServicesInstructions) Status

func (it *ManyServicesInstructions) Status(
	errCollection *errwrappers.Collection,
) (isSuccess bool)

type Request

type Request struct {
	ServiceName string
	Action      servicestate.Action
}

func (Request) CompiledErrorWrapper

func (it Request) CompiledErrorWrapper() *errorwrapper.Wrapper

func (Request) Disable

func (it Request) Disable() *Result

func (*Request) Dispose added in v0.8.9

func (it *Request) Dispose()

func (Request) Enable

func (it Request) Enable() *Result

func (Request) Exec added in v0.8.9

func (it Request) Exec(
	isDetailedError,
	isIgnoreUnknownService bool,
) (*Result, *errorwrapper.Wrapper)

func (Request) ExecDefault added in v0.8.9

func (it Request) ExecDefault() (*Result, *errorwrapper.Wrapper)

ExecDefault

Returns error for detailed action, use ExecSimple or Exec for simple error

func (Request) ExecDetailed added in v0.8.9

func (it Request) ExecDetailed() (*Result, *errorwrapper.Wrapper)

func (Request) ExecDetailedError added in v0.8.9

func (it Request) ExecDetailedError() *errorwrapper.Wrapper

func (Request) ExecError added in v0.8.9

func (it Request) ExecError(isDetailedError bool) *errorwrapper.Wrapper

func (Request) ExecSimple added in v0.8.9

func (it Request) ExecSimple() (*Result, *errorwrapper.Wrapper)

func (Request) ExecSimpleError added in v0.8.9

func (it Request) ExecSimpleError() *errorwrapper.Wrapper

func (Request) IsRunning

func (it Request) IsRunning() bool

func (Request) IsServiceExist

func (it Request) IsServiceExist() bool

func (Request) IsUnknownService

func (it Request) IsUnknownService() bool

func (Request) ReferenceValues

func (it Request) ReferenceValues() []ref.Value

func (Request) Reload

func (it Request) Reload() *Result

func (Request) ReloadError added in v0.8.9

func (it Request) ReloadError(isDetailed bool) *errorwrapper.Wrapper

func (Request) Restart

func (it Request) Restart() *Result

func (Request) RestartError added in v0.8.9

func (it Request) RestartError(isDetailed bool) *errorwrapper.Wrapper

func (Request) Run

func (it Request) Run() *Result

func (Request) SimplifiedErrorWrapper

func (it Request) SimplifiedErrorWrapper() *errorwrapper.Wrapper

func (Request) Start

func (it Request) Start() *Result

func (Request) StartError added in v0.8.9

func (it Request) StartError(isDetailed bool) *errorwrapper.Wrapper

func (Request) Status

func (it Request) Status() *Result

func (Request) Stop

func (it Request) Stop() *Result

func (Request) StopError added in v0.8.9

func (it Request) StopError(isDetailed bool) *errorwrapper.Wrapper

func (Request) StopSleepStart

func (it Request) StopSleepStart(
	sleep time.Duration,
) (stop, start *Result, isRunSuccess bool)

func (Request) VerifyExitCode

func (it Request) VerifyExitCode(exitCode linuxservicestate.ExitCode) *errorwrapper.Wrapper

type Result

type Result struct {
	Request      Request
	CmdOnce      *errcmd.CmdOnce
	ErrorWrapper *errorwrapper.Wrapper
	ExitCode     linuxservicestate.ExitCode
}

func GetStatusResult

func GetStatusResult(serviceName string) *Result

func Restart added in v0.8.9

func Restart(
	isDetailedError,
	isIgnoreUnknownService bool,
	action servicestate.Action,
	servicesName string,
) (*Result, *errorwrapper.Wrapper)

func Run

func Run(
	action servicestate.Action,
	serviceName string,
) *Result

func RunAction added in v0.8.9

func RunAction(
	isDetailedError,
	isIgnoreUnknownService bool,
	action servicestate.Action,
	servicesName string,
) (*Result, *errorwrapper.Wrapper)

func (*Result) CollectError

func (it *Result) CollectError(
	errCollection *errwrappers.Collection,
	isSimpleError bool,
) bool

func (*Result) CollectSimpleError

func (it *Result) CollectSimpleError(
	errCollection *errwrappers.Collection,
) bool

func (*Result) CompiledErrorWrapper

func (it *Result) CompiledErrorWrapper() *errorwrapper.Wrapper

func (*Result) Dispose added in v0.8.9

func (it *Result) Dispose()

func (*Result) DisposeWithoutErrorWrapper added in v0.8.9

func (it *Result) DisposeWithoutErrorWrapper()

func (*Result) ErrorWrapperUsingOpt

func (it *Result) ErrorWrapperUsingOpt(isDetailedErr bool) *errorwrapper.Wrapper

func (*Result) IsEmpty

func (it *Result) IsEmpty() bool

func (*Result) IsFailed

func (it *Result) IsFailed() bool

func (*Result) IsSuccess

func (it *Result) IsSuccess() bool

func (*Result) IsUnknownService

func (it *Result) IsUnknownService() bool

func (*Result) ServiceName

func (it *Result) ServiceName() string

func (*Result) SimplifiedError

func (it *Result) SimplifiedError() *errorwrapper.Wrapper

func (*Result) VerifyExitCode

func (it *Result) VerifyExitCode(expectedExitCode linuxservicestate.ExitCode) *errorwrapper.Wrapper

type Results

type Results struct {
	Items []*Result
}

func EmptyResults

func EmptyResults() *Results

func NewResults

func NewResults(capacity int) *Results

func RunServicesResults

func RunServicesResults(
	isDetailedError,
	isContinueOnErr bool,
	isIgnoreUnknownService bool,
	errCollection *errwrappers.Collection,
	action servicestate.Action,
	servicesNames ...string,
) *Results

func (*Results) Add

func (it *Results) Add(action servicestate.Action, serviceName string) linuxservicestate.ExitCode

func (*Results) AddServices

func (it *Results) AddServices(
	isContinueOnError bool,
	action servicestate.Action,
	servicesNames ...string,
) *Results

func (*Results) HasAnyFailed

func (it *Results) HasAnyFailed() bool

func (*Results) HasAnyItem

func (it *Results) HasAnyItem() bool

func (*Results) IsAllSuccess

func (it *Results) IsAllSuccess() bool

func (*Results) IsEmpty

func (it *Results) IsEmpty() bool

func (*Results) Length

func (it *Results) Length() int

type ServicesInstruction

type ServicesInstruction struct {
	IsDetailedError      bool                       `json:"IsDetailedError,omitempty"`
	IsContinueOnError    bool                       `json:"IsContinueOnError,omitempty"`
	StopServicesNames    []string                   `json:"StopServicesNames,omitempty"`
	StartServicesNames   []string                   `json:"StartServicesNames,omitempty"`
	RestartServicesNames []string                   `json:"RestartServicesNames,omitempty"`
	DisableServicesNames []string                   `json:"DisableServicesNames,omitempty"`
	EnableServicesNames  []string                   `json:"EnableServicesNames,omitempty"`
	StatusServicesNames  []string                   `json:"StatusServicesNames,omitempty"`
	Services             ManyServicesInstructions   `json:"Instructions,omitempty"`
	Validations          *StateValidateInstructions `json:"Validations,omitempty"`
}

func (*ServicesInstruction) Apply

func (it *ServicesInstruction) Apply(errCollection *errwrappers.Collection) (isSuccess bool)

func (*ServicesInstruction) HasDisableServicesNames

func (it *ServicesInstruction) HasDisableServicesNames() bool

func (*ServicesInstruction) HasEnableServicesNames

func (it *ServicesInstruction) HasEnableServicesNames() bool

func (*ServicesInstruction) HasRestartServicesNames

func (it *ServicesInstruction) HasRestartServicesNames() bool

func (*ServicesInstruction) HasServices

func (it *ServicesInstruction) HasServices() bool

func (*ServicesInstruction) HasStartServicesNames

func (it *ServicesInstruction) HasStartServicesNames() bool

func (*ServicesInstruction) HasStatusServicesNames

func (it *ServicesInstruction) HasStatusServicesNames() bool

func (*ServicesInstruction) HasStopServicesNames

func (it *ServicesInstruction) HasStopServicesNames() bool

func (*ServicesInstruction) HasValidations

func (it *ServicesInstruction) HasValidations() bool

type SimpleInstruction

type SimpleInstruction struct {
	ServiceName     string
	Action          servicestate.Action
	IsDetailedError bool
	// contains filtered or unexported fields
}

func (*SimpleInstruction) Apply

func (it *SimpleInstruction) Apply() *errorwrapper.Wrapper

func (*SimpleInstruction) ApplyOnErrorCollection

func (it *SimpleInstruction) ApplyOnErrorCollection(
	errCollection *errwrappers.Collection,
) (isSuccess bool)

func (*SimpleInstruction) CommandLine

func (it *SimpleInstruction) CommandLine() string

func (*SimpleInstruction) CompiledError

func (it *SimpleInstruction) CompiledError() *errorwrapper.Wrapper

func (*SimpleInstruction) DetailedOutput

func (it *SimpleInstruction) DetailedOutput() string

func (*SimpleInstruction) LazyRun

func (it *SimpleInstruction) LazyRun() *Result

func (*SimpleInstruction) LazyStatus

func (it *SimpleInstruction) LazyStatus() linuxservicestate.ExitCode

func (*SimpleInstruction) OutputLines

func (it *SimpleInstruction) OutputLines() []string

func (*SimpleInstruction) Run

func (it *SimpleInstruction) Run() *Result

func (*SimpleInstruction) Status

type StateValidateInstruction

type StateValidateInstruction struct {
	ServiceName      string
	ExpectedExitCode linuxservicestate.ExitCode
}

func (*StateValidateInstruction) Apply

func (*StateValidateInstruction) ApplyUsingErrCollection

func (it *StateValidateInstruction) ApplyUsingErrCollection(
	errCollection *errwrappers.Collection,
) (isSuccess bool)

func (*StateValidateInstruction) IsEmpty

func (it *StateValidateInstruction) IsEmpty() bool

type StateValidateInstructions

type StateValidateInstructions struct {
	IsContinueOnError bool
	Validations       []StateValidateInstruction `json:"Validations,omitempty"`
}

func (*StateValidateInstructions) ApplyUsingErrCollection

func (it *StateValidateInstructions) ApplyUsingErrCollection(
	errCollection *errwrappers.Collection,
) (isSuccess bool)

func (*StateValidateInstructions) HasValidations

func (it *StateValidateInstructions) HasValidations() bool

func (*StateValidateInstructions) IsEmpty

func (it *StateValidateInstructions) IsEmpty() bool

Jump to

Keyboard shortcuts

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