running

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const InstanceDelimiter = ':'

InstanceDelimiter is the delimiter of the app and instance name.

Variables

This section is empty.

Functions

func Check

func Check(cmdCtx *cmdcontext.CmdCtx, run *InstanceCtx) error

Check returns the result of checking the syntax of the application file.

func ExtractActiveAppNames added in v1.1.1

func ExtractActiveAppNames(instances []InstanceCtx) []string

ExtractActiveAppNames returns the names of applications, that have a running instance.

func ExtractActiveInstanceNames added in v1.1.1

func ExtractActiveInstanceNames(instances []InstanceCtx) []string

ExtractActiveInstanceNames returns the names of running instances.

func ExtractAppNames added in v1.1.1

func ExtractAppNames(instances []InstanceCtx) []string

ExtractAppNames returns the names of apps.

func ExtractInactiveAppNames added in v1.1.1

func ExtractInactiveAppNames(instances []InstanceCtx) []string

ExtractInactiveAppNames returns the names of applications, that have a not running instance.

func ExtractInactiveInstanceNames added in v1.1.1

func ExtractInactiveInstanceNames(instances []InstanceCtx) []string

ExtractInactiveInstanceNames returns the names of not running instances.

func ExtractInstanceNames added in v1.1.1

func ExtractInstanceNames(instances []InstanceCtx) []string

ExtractInstanceNames returns the names of instances.

func FillCtx

func FillCtx(cliOpts *config.CliOpts, cmdCtx *cmdcontext.CmdCtx,
	runningCtx *RunningCtx, args []string) error

FillCtx fills the RunningCtx context.

func GetAppInstanceName added in v0.3.0

func GetAppInstanceName(instance InstanceCtx) string

GetAppInstanceName returns the full instance name for the passed context. If an application is multi-instance, the format will be AppName:InstName. Otherwise, the format is AppName.

func IsAbleToStartInstances added in v1.3.0

func IsAbleToStartInstances(instances []InstanceCtx, cmdCtx *cmdcontext.CmdCtx) (
	bool, string)

IsAbleToStartInstances checks if it is possible to start instances.

func IsInstanceActive added in v1.1.1

func IsInstanceActive(instance *InstanceCtx) bool

IsInstanceActive returns true if the instance have running status.

func IsInstanceInactive added in v1.1.1

func IsInstanceInactive(instance *InstanceCtx) bool

IsInstanceInactive return true if the instance have not running status.

func Logrotate

func Logrotate(run *InstanceCtx) (string, error)

Logrotate rotates logs of a started tarantool instance.

func NewArtifactsPathBuilder added in v1.0.0

func NewArtifactsPathBuilder(baseDir, appName string) *artifactsPathBuilder

NewArtifactsPathBuilder creates new builder for paths generation.

func Run

func Run(runOpts *RunOpts, scriptPath string) error

Run runs an Instance.

func Start

func Start(cmdCtx *cmdcontext.CmdCtx, inst *InstanceCtx) error

Start an Instance.

func Status

Status returns the status of the Instance.

func Stop

func Stop(run *InstanceCtx) error

Stop the Instance.

Types

type Instance

type Instance interface {
	// Start starts the Instance with the specified parameters.
	Start() error

	// Run runs tarantool interpreter.
	Run(flags RunFlags) error

	// Wait waits for the process to complete.
	Wait() error

	// SendSignal sends a signal to the process.
	SendSignal(sig os.Signal) error

	// IsAlive verifies that the instance is alive.
	IsAlive() bool

	// Stop terminates the process.
	//
	// waitTimeout - the time that was provided to the process
	// to terminate correctly before killing it.
	Stop(waitTimeout time.Duration) error
}

Instance describes a running tarantool instance.

type InstanceCtx

type InstanceCtx struct {
	// AppDir is an application directory.
	AppDir string
	// InstanceScript is a script to run if any.
	InstanceScript string
	// AppName contains the name of the application as it was passed on start.
	AppName string
	// Instance name.
	InstName string
	// Directory that stores various instance runtime artifacts like
	// console socket, PID file, etc.
	RunDir string
	// Directory that stores log files.
	LogDir string
	// Log is the name of log file.
	Log string
	// WalDir is a directory where write-ahead log (.xlog) files are stored.
	WalDir string
	// MemtxDir is a directory where memtx stores snapshot (.snap) files.
	MemtxDir string `mapstructure:"memtx_dir" yaml:"memtx_dir"`
	// VinylDir is a directory where vinyl files or subdirectories will be stored.
	VinylDir string `mapstructure:"vinyl_dir" yaml:"vinyl_dir"`
	// LogMaxSize is the maximum size in megabytes of the log file
	// before it gets rotated. It defaults to 100 megabytes.
	LogMaxSize int
	// LogMaxBackups is the maximum number of old log files to retain.
	// The default is to retain all old log files (though LogMaxAge may
	// still cause them to get deleted).
	LogMaxBackups int
	// LogMaxAge is the maximum number of days to retain old log files
	// based on the timestamp encoded in their filename. Note that a
	// day is defined as 24 hours and may not exactly correspond to
	// calendar days due to daylight savings, leap seconds, etc. The
	// default is not to remove old log files based on age.
	LogMaxAge int
	// The name of the file with the watchdog PID under which the
	// instance was started.
	PIDFile string
	// If the instance is started under the watchdog it should
	// restart on if it crashes.
	Restartable bool
	// Control UNIX socket for started instance.
	ConsoleSocket string
	// True if this is a single instance application (no instances.yml).
	SingleApp bool
	// ClusterConfigPath is a path of cluster configuration.
	ClusterConfigPath string
	// Configuration is instance configuration loaded from cluster config.
	Configuration cluster.InstanceConfig
}

InstanceCtx contains information about application instance.

func CollectInstances added in v1.0.0

func CollectInstances(appName string, applicationsDir string) ([]InstanceCtx, error)

CollectInstances searches all instances available in application.

type Provider

type Provider interface {
	// CreateInstance is used to create a new instance on restart.
	CreateInstance(logger *ttlog.Logger) (Instance, error)
	// UpdateLogger updates the logger settings or creates a new logger,
	// if passed nil.
	UpdateLogger(logger *ttlog.Logger) (*ttlog.Logger, error)
	// IsRestartable checks
	IsRestartable() (bool, error)
}

Provider interface provides Watchdog methods to get objects whose creation and updating may depend on changing external parameters (such as configuration file).

type RunFlags

type RunFlags struct {
	// RunEval contains "-e" flag content.
	RunEval string
	// RunLib contains "-l" flag content.
	RunLib string
	// RunInteractive contains "-i" flag content.
	RunInteractive bool
	// RunStdin contains "-" flag content.
	RunStdin string
	// RunVersion contains "-v" flag content.
	RunVersion bool
	// RunArgs contains command args.
	RunArgs []string
}

RunFlags contains flags for tt run.

type RunOpts

type RunOpts struct {
	CmdCtx     cmdcontext.CmdCtx
	RunningCtx RunningCtx
	RunFlags   RunFlags
}

RunOpts contains information for tt run.

type RunningCtx

type RunningCtx struct {
	// Instances contains information about application instances.
	Instances []InstanceCtx
}

Running contains information about application instances.

type Watchdog

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

Watchdog is a process that controls an Instance process.

func NewWatchdog

func NewWatchdog(restartable bool, restartTimeout time.Duration, logger *ttlog.Logger,
	provider Provider, preStartAction func() error) *Watchdog

NewWatchdog creates a new instance of Watchdog.

func (*Watchdog) Start

func (wd *Watchdog) Start() error

Start starts the Instance and signal handling.

Jump to

Keyboard shortcuts

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