caretakerd

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 18 Imported by: 0

README

Continuous Integration Go Report Card Code Climate

caretakerd

caretakerd is a simple process supervisor. There are no external dependencies and it is optimized for containerization (like Docker) and simple configuration.

Documentation

For general documentation, please refer to caretakerd.echocat.org.

For specific versions, please refer to caretakerd.echocat.org/all/.

Building

Requirements

To build caretakerd, you only need:

  • a compatible operating system (Linux, Windows or Mac OS X)
  • a working Go (at least version 1.11)

The build system will download every dependency and build it if necessary.

Run

To run caretakerd, invoke the following:

# Run all tests
go run ./build test

# Build binaries
go run ./build build
Build artifacts
  • You can find the compiled and linked binaries under ./var/binaries/
  • You can find the generated document under ./var/manuals/
  • You can find the packaged TARZs and ZIPs under ./var/dist/

Contributing

caretakerd is an open source project by echocat. So if you want to make this project even better, you can contribute to this project on GitHub by fork us.

If you commit code to this project, you have to accept that this code will be released under the license of this project.

Support

If you need support you can create a ticket in our issue tracker or join our chat at echocat.slack.com/messages/caretakerd.

License

See the LICENSE file.

Documentation

Index

Constants

View Source
const (
	// BaseName indicates the base name of the caretaker executable
	BaseName = "caretaker"
	// DaemonName indicates the name of the caretakerd executable
	DaemonName = "caretakerd"
	// ControlName indicates the name of the caretakerctl executable
	ControlName = "caretakerctl"
	// Description indicates the description of caretakerd.
	Description = "" /* 164-byte string literal not displayed */
	// URL indicates the URL of the caretakerd project page.
	URL = "https://caretakerd.echocat.org"
)

Variables

This section is empty.

Functions

func IsConfigNotExists added in v0.2.0

func IsConfigNotExists(err error) bool

IsConfigNotExists returns true if err matches ConfigDoesNotExistError

Types

type Appendable

type Appendable interface {
	Append(value string) error
}

Appendable indicates an instance where a string can be appended.

type Caretakerd

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

Caretakerd instance structure

func NewCaretakerd

func NewCaretakerd(conf *Config, syncGroup *usync.Group) (*Caretakerd, error)

NewCaretakerd creates a new Caretakerd instance from the given config

func (*Caretakerd) Close

func (instance *Caretakerd) Close()

Close closes the caretakerd instance and clears resources. After calling this method it is no longer possible to use this instance.

func (*Caretakerd) ConfigObject

func (instance *Caretakerd) ConfigObject() interface{}

ConfigObject returns the config that was used to create this instances.

func (*Caretakerd) Control

func (instance *Caretakerd) Control() *control.Control

Control returns the instantiated control that belongs to this instance.

func (Caretakerd) IsOpen

func (instance Caretakerd) IsOpen() bool

IsOpen returns "true" if caretakerd is still open. This should return "false" after Close() was called.

func (*Caretakerd) KeyStore

func (instance *Caretakerd) KeyStore() *keyStore.KeyStore

KeyStore returns the instantiated keyStore that belongs to this instance.

func (Caretakerd) Logger

func (instance Caretakerd) Logger() *logger.Logger

Logger returns the instantiated logger that belongs to this instance.

func (*Caretakerd) Run

func (instance *Caretakerd) Run() (values.ExitCode, error)

Run starts every services and required resources of caretakerd. This is a blocking method.

func (*Caretakerd) Services

func (instance *Caretakerd) Services() *service.Services

Services returns the instantiated services that belong to this instance.

func (*Caretakerd) Stop

func (instance *Caretakerd) Stop()

Stop stops this instance (if it is running). This method is blocking until every service and resource is stopped.

type Config

type Config struct {
	// Defines how the encryption of caretakerd works.
	// This is especially important if {@ref #RPC RPC} is used.
	//
	// For details see {@ref github.com/echocat/caretakerd/keyStore.Config}.
	KeyStore keyStore.Config `json:"keyStore" yaml:"keyStore,omitempty"`

	// Defines how caretaker can controlled remotely.
	//
	// For details see {@ref github.com/echocat/caretakerd/rpc.Config}.
	RPC rpc.Config `json:"rpc" yaml:"rpc,omitempty"`

	// Defines the access rights of caretakerctl to caretakerd.
	// This requires {@ref #RPC RPC} enabled.
	//
	// For details see {@ref github.com/echocat/caretakerd/control.Config}.
	Control control.Config `json:"control" yaml:"control,omitempty"`

	// Configures the logger for caretakerd itself.
	// This does not include output of services.
	//
	// For details see {@ref github.com/echocat/caretakerd/logger.Config}.
	Logger logger.Config `json:"logger" yaml:"logger,omitempty"`

	// Services configuration to run with caretakerd.
	//
	// > **Important**: This is a map and requires exact one service
	// > configured as {@ref github.com/echocat/caretakerd/service.Config#Type type} = {@ref github.com/echocat/caretakerd/service.Type#Master master}.
	//
	// For details see {@ref github.com/echocat/caretakerd/service.Config}.
	Services service.Configs `json:"services" yaml:"services,omitempty"`

	// Contains the source where this config comes from.
	Source values.String `json:"-" yaml:"-"`
}

Root configuration of caretakerd.

func LoadFromYamlFile

func LoadFromYamlFile(platform string, fileName values.String) (Config, error)

LoadFromYamlFile loads the caretakerd config from the given yaml file.

func NewConfigFor added in v0.2.0

func NewConfigFor(platform string) Config

NewConfigFor create a new config instance.

func (Config) EnrichFromEnvironment

func (instance Config) EnrichFromEnvironment() Config

EnrichFromEnvironment enriches the current Config instance with configuration from the environment variables.

func (*Config) UnmarshalYAML added in v1.0.0

func (instance *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML is used by yaml unmarshalling. Do not call direct.

func (Config) Validate

func (instance Config) Validate() error

Validate do validate action on this object and return an error object if any.

func (Config) ValidateMaster

func (instance Config) ValidateMaster() error

ValidateMaster return an error instance on every validation problem of the master service config instance.

func (Config) WriteToYamlFile

func (instance Config) WriteToYamlFile(fileName values.String) error

WriteToYamlFile writes the config of the current instance to the given yaml file.

type ConfigDoesNotExistError

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

ConfigDoesNotExistError descripts an error if a config does not exists.

func (ConfigDoesNotExistError) Error

func (instance ConfigDoesNotExistError) Error() string

Error returns the error message.

type Executable

type Executable interface {
	Services() *service.Services
	KeyStore() *keyStore.KeyStore
	Logger() *logger.Logger
}

Executable indicates an object that could be executed.

type Execution

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

Execution is an instance of an execution of every service of caretakerd.

func NewExecution

func NewExecution(executable Executable) *Execution

NewExecution creates a new Execution instance of caretakerd.

Hint: A caretakerd Execution instance could only be called once.

func (*Execution) GetCountOfActiveExecutions

func (instance *Execution) GetCountOfActiveExecutions() int

GetCountOfActiveExecutions returns the number of active executions of all services.

func (*Execution) GetFor

func (instance *Execution) GetFor(s *service.Service) (*service.Execution, bool)

GetFor queries the current active service execution for the given service. Returns "false" if no current execution matches.

func (*Execution) Information

func (instance *Execution) Information() map[string]service.Information

Information returns an information object that contains information for every configured service.

func (*Execution) InformationFor

func (instance *Execution) InformationFor(s *service.Service) service.Information

InformationFor returns an information object for the given service.

func (*Execution) Kill

func (instance *Execution) Kill(target *service.Service) error

Kill kills the given service.

func (*Execution) Restart

func (instance *Execution) Restart(target *service.Service) error

Restart stops and restarts the given service.

func (*Execution) Run

func (instance *Execution) Run() (values.ExitCode, error)

Run starts the caretakerd execution, every service and required resource. This is a blocking method.

func (*Execution) Signal

func (instance *Execution) Signal(target *service.Service, what values.Signal) error

Signal sends the given signal to the given service.

func (*Execution) Start

func (instance *Execution) Start(target *service.Service) error

Start starts the given service. This is not a blocking method.

func (*Execution) Stop

func (instance *Execution) Stop(target *service.Service) error

Stop stops the given service.

func (*Execution) StopAll

func (instance *Execution) StopAll()

StopAll stop all running serivces.

type Putable

type Putable interface {
	Put(key string, value string) error
}

Putable indicates an instance of a kind of map where a value with a key could be putted to.

Jump to

Keyboard shortcuts

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