launchlib

package
v1.124.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TemplateDelimsOpen  = "{{"
	TemplateDelimsClose = "}}"
	// ExecPathBlackListRegex matches characters disallowed in paths we allow to be passed to exec()
	ExecPathBlackListRegex = `[^\w.\/_\-]`
	BytesInMebibyte        = 1048576
)
View Source
const (
	CheckPeriod = 5 * time.Second
)

Variables

View Source
var DefaultCGroupV1Pather = CGroupV1Pather{
	// contains filtered or unexported fields
}
View Source
var DefaultCGroupV1ProcessorCounter = CGroupV1ProcessorCounter{
	// contains filtered or unexported fields
}
View Source
var DefaultMemoryLimit = NewCGroupMemoryLimit(os.DirFS("/"))

Functions

func ComputeJVMHeapSizeInBytes added in v1.93.0

func ComputeJVMHeapSizeInBytes(hostProcessorCount int, cgroupMemoryLimitInBytes uint64) (uint64, error)

ComputeJVMHeapSizeInBytes If the experimental `ContainerV2` is set to `true` (which it is by default), compute the heap size to be 75% of the heap minus 3mb per processor, with a minimum value of 50% of the heap.

func GetConfigsFromFiles

func GetConfigsFromFiles(
	staticConfigFile string, customConfigFile string, stdout io.Writer) (
	PrimaryStaticLauncherConfig, PrimaryCustomLauncherConfig, error)

func IsPidAlive

func IsPidAlive(pid int) bool

func IsProcessAlive

func IsProcessAlive(process *os.Process) bool

func MkDirs

func MkDirs(dirs []string, stdout io.Writer) error

func SignalPid

func SignalPid(pid int, sign os.Signal) error

Types

type AllowedLauncherConfigValues

type AllowedLauncherConfigValues struct {
	ConfigTypes    map[string]struct{}
	ConfigVersions map[int]struct{}
	Executables    map[string]struct{}
}

type CGroupMemoryLimit added in v1.93.0

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

func (CGroupMemoryLimit) MemoryLimitInBytes added in v1.93.0

func (c CGroupMemoryLimit) MemoryLimitInBytes() (uint64, error)

type CGroupName added in v1.63.0

type CGroupName string

type CGroupPather added in v1.63.0

type CGroupPather interface {
	Path(name CGroupName) (string, error)
}

func NewCGroupV1Pather added in v1.63.0

func NewCGroupV1Pather(filesystem fs.FS) CGroupPather

type CGroupV1Pather added in v1.63.0

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

func (CGroupV1Pather) Path added in v1.63.0

func (c CGroupV1Pather) Path(name CGroupName) (string, error)

Path implements CGroupPather

type CGroupV1ProcessorCounter added in v1.61.0

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

func (CGroupV1ProcessorCounter) ProcessorCount added in v1.61.0

func (c CGroupV1ProcessorCounter) ProcessorCount() (uint, error)

type CreateLogger

type CreateLogger func() (io.WriteCloser, error)

type CustomLauncherConfig

type CustomLauncherConfig struct {
	TypedConfig             `yaml:",inline"`
	JvmOpts                 []string                   `yaml:"jvmOpts"`
	Env                     map[string]string          `yaml:"env"`
	Experimental            ExperimentalLauncherConfig `yaml:"experimental"`
	DisableContainerSupport bool                       `yaml:"dangerousDisableContainerSupport"`
}

type ExperimentalLauncherConfig added in v1.61.0

type ExperimentalLauncherConfig struct {
	ContainerV2 *bool `yaml:"containerV2"`
}

type JavaConfig

type JavaConfig struct {
	JavaHome  string   `yaml:"javaHome"`
	MainClass string   `yaml:"mainClass" validate:"nonzero"`
	JvmOpts   []string `yaml:"jvmOpts"`
	Classpath []string `yaml:"classpath" validate:"nonzero"`
}

type MemoryLimit added in v1.93.0

type MemoryLimit interface {
	MemoryLimitInBytes() (uint64, error)
}

func NewCGroupMemoryLimit added in v1.93.0

func NewCGroupMemoryLimit(filesystem fs.FS) MemoryLimit

type NoopClosingWriter

type NoopClosingWriter struct {
	io.Writer
}

func (*NoopClosingWriter) Close

func (n *NoopClosingWriter) Close() error

type PrimaryCustomLauncherConfig

type PrimaryCustomLauncherConfig struct {
	VersionedConfig      `yaml:",inline"`
	CustomLauncherConfig `yaml:",inline"`
	SubProcesses         map[string]CustomLauncherConfig `yaml:"subProcesses"`
	CgroupsV1            map[string]string               `yaml:"cgroupsV1"`
}

type PrimaryStaticLauncherConfig

type PrimaryStaticLauncherConfig struct {
	VersionedConfig      `yaml:",inline"`
	ServiceName          string `yaml:"serviceName"`
	StaticLauncherConfig `yaml:",inline"`
	SubProcesses         map[string]StaticLauncherConfig `yaml:"subProcesses"`
}

type ProcessMonitor

type ProcessMonitor struct {
	PrimaryPID     int
	SubProcessPIDs []int
}

func (*ProcessMonitor) ForwardSignals

func (m *ProcessMonitor) ForwardSignals()

func (*ProcessMonitor) KillSubProcesses

func (m *ProcessMonitor) KillSubProcesses() error

func (*ProcessMonitor) Run

func (m *ProcessMonitor) Run() error

func (*ProcessMonitor) SignalSubProcesses

func (m *ProcessMonitor) SignalSubProcesses(sign os.Signal) error

func (*ProcessMonitor) TermProcessGroupOnDeath

func (m *ProcessMonitor) TermProcessGroupOnDeath() error

type ProcessorCounter added in v1.61.0

type ProcessorCounter interface {
	ProcessorCount() (uint, error)
}

func NewCGroupV1ProcessorCounter added in v1.61.0

func NewCGroupV1ProcessorCounter(filesystem fs.FS) ProcessorCounter

type ServiceCmds

type ServiceCmds struct {
	Primary      *exec.Cmd
	SubProcesses map[string]*exec.Cmd
}

func CompileCmdsFromConfig

func CompileCmdsFromConfig(
	staticConfig *PrimaryStaticLauncherConfig, customConfig *PrimaryCustomLauncherConfig, loggers ServiceLoggers) (
	serviceCmds *ServiceCmds, err error)

type ServiceLoggers

type ServiceLoggers interface {
	PrimaryLogger() (io.WriteCloser, error)
	SubProcessLogger(name string) CreateLogger
}

type SimpleWriterLogger

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

func NewSimpleWriterLogger

func NewSimpleWriterLogger(writer io.Writer) *SimpleWriterLogger

func (*SimpleWriterLogger) PrimaryLogger

func (s *SimpleWriterLogger) PrimaryLogger() (io.WriteCloser, error)

func (*SimpleWriterLogger) SubProcessLogger

func (s *SimpleWriterLogger) SubProcessLogger(name string) CreateLogger

type StaticLauncherConfig

type StaticLauncherConfig struct {
	TypedConfig `yaml:",inline"`
	JavaConfig  `yaml:",inline"`
	Env         map[string]string `yaml:"env"`
	Executable  string            `yaml:"executable,omitempty"`
	Args        []string          `yaml:"args"`
	Dirs        []string          `yaml:"dirs"`
}

type TypedConfig

type TypedConfig struct {
	Type string `yaml:"configType"`
}

type VersionedConfig

type VersionedConfig struct {
	Version int `yaml:"configVersion"`
}

Jump to

Keyboard shortcuts

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