running

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: BSD-2-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstStateStopped = process_utils.ProcStateStopped
	InstStateDead    = process_utils.ProcStateDead
	InstStateRunning = process_utils.ProcStateRunning
)

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 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 Logrotate

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

Logrotate rotates logs of a started tarantool instance.

func Run

func Run(runOpts *RunOpts, scriptPath string) error

Run runs an Instance.

func Start

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

Start an Instance.

func Status

func Status(run *InstanceCtx) string

Status returns the status of the Instance.

func Stop

func Stop(run *InstanceCtx) error

Stop the Instance.

Types

type Instance

type Instance struct {
	// Cmd represents an external command being prepared and run.
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

Instance describes a running process.

func NewInstance

func NewInstance(tarantoolPath string, appPath string, appName string, instName string,
	console_sock string, env []string, logger *ttlog.Logger, dataDir string) (*Instance, error)

NewInstance creates an Instance.

func (*Instance) IsAlive

func (inst *Instance) IsAlive() bool

IsAlive verifies that the Instance is alive by sending a "0" signal.

func (*Instance) Run

func (inst *Instance) Run(flags RunFlags) error

Run runs tarantool instance.

func (*Instance) SendSignal

func (inst *Instance) SendSignal(sig os.Signal) error

SendSignal sends a signal to the Instance.

func (*Instance) Start

func (inst *Instance) Start() error

Start starts the Instance with the specified parameters.

func (*Instance) Stop

func (inst *Instance) Stop(timeout time.Duration) error

Stop terminates the Instance.

timeout - the time that was provided to the process to terminate correctly before the "SIGKILL" signal is used.

func (*Instance) Wait

func (inst *Instance) Wait() error

Wait calls "Wait" for the process.

type InstanceCtx

type InstanceCtx struct {
	// Path to an application.
	AppPath 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
	// DataDir is the directory where all the instance artifacts
	// are stored.
	DataDir string
	// 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
}

InstanceCtx contains information about application instance.

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 {
	// Instance describes the controlled Instance.
	Instance *Instance
	// 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) *Watchdog

NewWatchdog creates a new instance of Watchdog.

func (*Watchdog) Start

func (wd *Watchdog) Start()

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