system

package
v0.0.0-...-f532095 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCommand

func ExecCommand(name string, args []string) (string, error)

ExecCommand command execution

func WriteFile

func WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile tries to create parent directory before WriteFile.

Types

type Action

type Action struct {
	Name string `json:"name"`
}

Action is the system action.

type ActionStatus

type ActionStatus struct {
	Status bool   `json:"status"`
	Text   string `json:"text"`
}

ActionStatus is the status of action.

type Launcher

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

Launcher supervises the process status, start, stop and restart.

func NewLauncher

func NewLauncher(pidFile, cmd string) *Launcher

NewLauncher creates new system.

func (*Launcher) IsAlive

func (s *Launcher) IsAlive() (int, bool)

IsAlive check if the process alive.

func (*Launcher) Restart

func (s *Launcher) Restart() (bool, error)

Restart restart the process

func (*Launcher) Start

func (s *Launcher) Start() (bool, error)

Start starts the process.

func (*Launcher) Stop

func (s *Launcher) Stop() bool

Stop stops the process.

type Stats

type Stats interface {
	// Reset the RabbitMQ StatsDB, A node may be randomly selected
	Reset() (bool, string, error)
	// Terminate the RabbitMQ StatsDB, Not to choose the node
	Terminate() (bool, string, error)
	// Crash the RabbitMQ StatsDB, Not to choose the node
	Crash() (bool, string, error)
}

Stats represents a stats interface

type StatsController

type StatsController struct {
	Stats
}

StatsController controls the RabbitMQ StatsDB

func (*StatsController) Handle

func (c *StatsController) Handle(action *Action) *ActionStatus

Handle handle action

type StatsDBCtl

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

StatsDBCtl is the RabbitMQ statsdb control system

func NewStatsDBCtl

func NewStatsDBCtl() *StatsDBCtl

NewStatsDBCtl creates a new StatsDBCtl instance

func (*StatsDBCtl) Crash

func (s *StatsDBCtl) Crash() (bool, string, error)

Crash crash the RabbitMQ statsdb

func (*StatsDBCtl) Reset

func (s *StatsDBCtl) Reset() (bool, string, error)

Reset reset the RabbitMQ statsdb

func (*StatsDBCtl) Terminate

func (s *StatsDBCtl) Terminate() (bool, string, error)

Terminate terminate the RabbitMQ statsdb

type Supervisor

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

Supervisor is the supervisor process control system.

func NewSupervisor

func NewSupervisor(service string) *Supervisor

NewSupervisor creates new Supervisor instance.

func (*Supervisor) IsAlive

func (s *Supervisor) IsAlive() (int, bool)

IsAlive gets results from `supervisorctl status [service]`

func (*Supervisor) Restart

func (s *Supervisor) Restart() (bool, error)

Restart executes `supervisorctl restart [service]`

func (*Supervisor) Start

func (s *Supervisor) Start() (bool, error)

Start executes `supervisorctl start [service]`

func (*Supervisor) Stop

func (s *Supervisor) Stop() bool

Stop executes `supervisorctl stop [service]`

type SysController

type SysController struct {
	System
}

SysController controls the System.

func (*SysController) Handle

func (c *SysController) Handle(action *Action) *ActionStatus

Handle plays action.

type System

type System interface {
	// IsAlive checks process is alive.
	IsAlive() (int, bool)
	// Start starts process.
	Start() (bool, error)
	// Start restart process.
	Restart() (bool, error)
	// Stop stops process.
	Stop() bool
}

System is the interface of process control system.

type Systemd

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

Systemd is the systemd process control system.

func NewSystemd

func NewSystemd(service string) *Systemd

NewSystemd creates new Systemd instance.

func (*Systemd) IsAlive

func (s *Systemd) IsAlive() (int, bool)

IsAlive gets results from `systemctl is-active [service]`

func (*Systemd) Restart

func (s *Systemd) Restart() (bool, error)

Restart executes `systemctl restart [service]`

func (*Systemd) Start

func (s *Systemd) Start() (bool, error)

Start executes `systemctl start [service]`

func (*Systemd) Stop

func (s *Systemd) Stop() bool

Stop executes `systemctl stop [service]`

Jump to

Keyboard shortcuts

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