linuxservicecmd

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 13 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) osserviceexit.Code

func IsLookPathExist

func IsLookPathExist(serviceName string) bool

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 RestartMultipleServices

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

func RunServices

func RunServices(
	isDetailedError,
	isContinueOnErr bool,
	isIgnoreUnknownService bool,
	errCollection *errwrappers.Collection,
	action osservicerun.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 StopMultipleServices

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

func StopStartMultipleServices

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

func VerifyExitCode

func VerifyExitCode(
	serviceName string,
	expectedExitCode osserviceexit.Code,
) *errorwrapper.Wrapper

Types

type CoreServicesInstruction

type CoreServicesInstruction struct {
	IsIgnoreUnknownService bool                `json:"IsIgnoreUnknownService,omitempty"`
	Action                 osservicerun.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 osservicerun.Action,
) (isSuccess bool)

func (*ManyServicesInstructions) Status

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

type Request

type Request struct {
	ServiceName string
	Action      osservicerun.Action
}

func (*Request) CompiledErrorWrapper

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

func (*Request) Disable

func (it *Request) Disable() *Result

func (*Request) Enable

func (it *Request) Enable() *Result

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) Restart

func (it *Request) Restart() *Result

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) Status

func (it *Request) Status() *Result

func (*Request) Stop

func (it *Request) Stop() *Result

func (*Request) StopSleepStart

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

func (*Request) VerifyExitCode

func (it *Request) VerifyExitCode(exitCode osserviceexit.Code) *errorwrapper.Wrapper

type Result

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

func GetStatusResult

func GetStatusResult(serviceName string) *Result

func Run

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

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) 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 osserviceexit.Code) *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 osservicerun.Action,
	servicesNames ...string,
) *Results

func (*Results) Add

func (it *Results) Add(action osservicerun.Action, serviceName string) osserviceexit.Code

func (*Results) AddServices

func (it *Results) AddServices(
	isContinueOnError bool,
	action osservicerun.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          osservicerun.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() osserviceexit.Code

func (*SimpleInstruction) OutputLines

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

func (*SimpleInstruction) Run

func (it *SimpleInstruction) Run() *Result

func (*SimpleInstruction) Status

func (it *SimpleInstruction) Status() osserviceexit.Code

type StateValidateInstruction

type StateValidateInstruction struct {
	ServiceName      string
	ExpectedExitCode osserviceexit.Code
}

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