system

package
v0.0.0-...-4578969 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Controller

type Controller struct {
	System
}

Controller controls the System.

func (*Controller) Handle

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

Handle plays 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 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 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