supervisor

package module
v0.0.0-...-260368e Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: MIT Imports: 10 Imported by: 3

README

supervisor

Golang XMLRPC client for supervisord

Documentation

Index

Constants

View Source
const (
	EVENT_BASE                             Event = "EVENT"
	EVENT_PROCESS_STATE                          = "PROCESS_STATE"
	EVENT_PROCESS_STATE_STARTING                 = "PROCESS_STATE_STARTING"
	EVENT_PROCESS_STATE_RUNNING                  = "PROCESS_STATE_RUNNING"
	EVENT_PROCESS_STATE_BACKOFF                  = "PROCESS_STATE_BACKOFF"
	EVENT_PROCESS_STATE_STOPPING                 = "PROCESS_STATE_STOPPING"
	EVENT_PROCESS_STATE_EXITED                   = "PROCESS_STATE_EXITED"
	EVENT_PROCESS_STATE_STOPPED                  = "PROCESS_STATE_STOPPED"
	EVENT_PROCESS_STATE_FATAL                    = "PROCESS_STATE_FATAL"
	EVENT_PROCESS_STATE_UNKNOWN                  = "PROCESS_STATE_UNKNOWN"
	EVENT_REMOTE_COMMUNICATION                   = "REMOTE_COMMUNICATION"
	EVENT_PROCESS_LOG                            = "PROCESS_LOG"
	EVENT_PROCESS_LOG_STDOUT                     = "PROCESS_LOG_STDOUT"
	EVENT_PROCESS_LOG_STDERR                     = "PROCESS_LOG_STDERR"
	EVENT_PROCESS_COMMUNICATION                  = "PROCESS_COMMUNICATION"
	EVENT_PROCESS_COMMUNICATION_STDOUT           = "PROCESS_COMMUNICATION_STDOUT"
	EVENT_PROCESS_COMMUNICATION_STDERR           = "PROCESS_COMMUNICATION_STDERR"
	EVENT_SUPERVISOR_STATE_CHANGE                = "SUPERVISOR_STATE_CHANGE"
	EVENT_SUPERVISOR_STATE_CHANGE_RUNNING        = "SUPERVISOR_STATE_CHANGE_RUNNING"
	EVENT_SUPERVISOR_STATE_CHANGE_STOPPING       = "SUPERVISOR_STATE_CHANGE_STOPPING"
	EVENT_TICK                                   = "TICK"
	EVENT_TICK_5                                 = "TICK_5"
	EVENT_TICK_60                                = "TICK_60"
	EVENT_TICK_3600                              = "TICK_3600"
	EVENT_PROCESS_GROUP                          = "PROCESS_GROUP"
	EVENT_PROCESS_GROUP_ADDED                    = "PROCESS_GROUP_ADDED "
	EVENT_PROCESS_GROUP_REMOVED                  = "PROCESS_GROUP_REMOVED"
)
View Source
const (
	GROUPS_ADDED   = "PROCESS_GROUPS_ADDED"
	GROUPS_CHANGED = "PROCESS_GROUPS_CHANGED"
	GROUPS_REMOVED = "PROCESS_GROUPS_REMOVED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(addr string, port int, username, password string) Client

func (Client) AddProcessGroup

func (c Client) AddProcessGroup(name string) (bool, error)

Update the config for a running process from the configuration file

func (Client) ApiVersion

func (c Client) ApiVersion() (string, error)

Returns the version of the RPC API used by supervisord

func (Client) ClearAllProcessLogs

func (c Client) ClearAllProcessLogs() error

Clear all process log files

func (Client) ClearProcessLogs

func (c Client) ClearProcessLogs(name string) error

Clear the stdout and stderr logs for the specified process and reopen them

func (Client) Clearlog

func (c Client) Clearlog() error

Clear the main log file

func (Client) GetAllProcessInfo

func (c Client) GetAllProcessInfo() ([]ProcessInfo, error)

Get info about all processes

func (Client) GetProcessInfo

func (c Client) GetProcessInfo(name string) (*ProcessInfo, error)

Get info about a specific process

func (Client) Identification

func (c Client) Identification() (string, error)

Result identifying string of supervisord

func (Client) Pid

func (c Client) Pid() (int64, error)

Return the PID of supervisord

func (Client) ReadLog

func (c Client) ReadLog(offset, length int) (string, error)

Read from the main supervisord log.

func (Client) ReadProcessStderr

func (c Client) ReadProcessStderr(name string, offset, length int) (string, error)

Read from the stderr for the specified process

func (Client) ReadProcessStdout

func (c Client) ReadProcessStdout(name string, offset, length int) (string, error)

Read from the stdout for specified process

func (Client) ReloadConfig

func (c Client) ReloadConfig() (map[string][]string, error)

Reload the configuration ( supervisorctl reread )

func (Client) RemoveProcessGroup

func (c Client) RemoveProcessGroup(name string) (bool, error)

Remove a stopped process group from the active configuration

func (Client) Restart

func (c Client) Restart() error

Restart the supervisor process

func (Client) SendProcessStdin

func (c Client) SendProcessStdin(name, chars string) error

Send a string of characters to the STDIN of the specified process

func (Client) SendRemoteCommEvent

func (c Client) SendRemoteCommEvent(t, data string) error

Send an event that will be received by any event listener subprocesses subscribing to the 'RemoteCommunicationEvent'

func (Client) Shutdown

func (c Client) Shutdown() error

Shutdown the supervisor process

func (Client) SignalAllProcesses

func (c Client) SignalAllProcesses(signal int) ([]*ProcessInfo, error)

Send an arbitrary UNIX signal to all processes listed in the configuration file

func (Client) SignalProcess

func (c Client) SignalProcess(name string, signal int) ([]*ProcessInfo, error)

Send an arbitrary UNIX signal to the process specified

func (Client) SignalProcessGroup

func (c Client) SignalProcessGroup(name string, signal int) ([]*ProcessInfo, error)

Send an arbitrary UNIX signal to all process in the group specified

func (Client) StartAllProcesses

func (c Client) StartAllProcesses(wait bool) ([]ProcessInfo, error)

Start all processes listed in the configuration file

func (Client) StartProcess

func (c Client) StartProcess(name string, wait bool) (bool, error)

Start a process

func (Client) StartProcessGroup

func (c Client) StartProcessGroup(name string, wait bool) ([]ProcessInfo, error)

Start all processes listed in the group specified

func (Client) State

func (c Client) State() (*State, error)

Return current state of supervisord as a struct

func (Client) StopAllProcesses

func (c Client) StopAllProcesses(wait bool) ([]ProcessInfo, error)

Stop all processes listed in the configuration file

func (Client) StopProcess

func (c Client) StopProcess(name string, wait bool) (bool, error)

Stop a process

func (Client) StopProcessGroup

func (c Client) StopProcessGroup(name string, wait bool) ([]ProcessInfo, error)

Stop all processes listed in the group specified

func (Client) SupervisorVersion

func (c Client) SupervisorVersion() (string, error)

Return the version of the supervisor package in use by supervisord

func (Client) TailProcessStderr

func (c Client) TailProcessStderr(name string, offset, length int) (string, error)

Provides a more efficient way to tail the stderr log

func (Client) TailProcessStdout

func (c Client) TailProcessStdout(name string, offset, length int) (string, error)

Provides a more efficient way to tail the stdout log

func (Client) Update

func (c Client) Update() error

Alternative for supervisorctl update

type Event

type Event string

type EventMessage

type EventMessage struct {
	Headers *HeaderToken
	Body    []byte
}

func NewEventMessage

func NewEventMessage(headers *HeaderToken, body []byte) EventMessage

func (EventMessage) AsMap

func (e EventMessage) AsMap() map[string]string

func (EventMessage) String

func (e EventMessage) String() string

type HeaderToken

type HeaderToken struct {
	Version    string `token:"ver"`        // The event system protocol version.
	Server     string `token:"server"`     // The identifier of the supervisord sending the event.
	Serial     int    `token:"serial"`     // An integer assigned to each event.
	Pool       string `token:"pool"`       // The name of the event listener pool which generated this event.
	PoolSerial int    `token:"poolserial"` // An integer assigned to each event by the eventlistener pool which is being sent from.
	EventName  Event  `token:"eventname"`  // The specific event type name.
	Length     int    `token:"len"`        // An integer indicating the number of bytes in the event payload.
}

func NewHeaderToken

func NewHeaderToken(header string) (*HeaderToken, error)

type Listener

type Listener struct {
	Stdin  *os.File
	Stdout *os.File
	Stderr *os.File
	// contains filtered or unexported fields
}

func NewListener

func NewListener() *Listener

func (*Listener) FilterEvents

func (l *Listener) FilterEvents(e []Event)

filter to specific event types

func (*Listener) FilterProcesses

func (l *Listener) FilterProcesses(p []string)

Filter to specific process names

func (*Listener) Listen

func (l *Listener) Listen()

Run this in a go-routine

func (*Listener) Messages

func (l *Listener) Messages() chan EventMessage

type ProcessInfo

type ProcessInfo struct {
	Name          string `xmlrpc:"name"`
	Group         string `xmlrpc:"group"`
	Description   string `xmlrpc:"description"`
	Start         int64  `xmlrpc:"start"`
	Stop          int64  `xmlrpc:"stop"`
	Now           int64  `xmlrpc:"now"`
	State         int64  `xmlrpc:"state"`
	StateName     string `xmlrpc:"statename"`
	SpawnErr      string `xmlrpc:"spawnerr"`
	ExitStatus    int64  `xmlrpc:"exitstatus"`
	StdoutLogFile string `xmlrpc:"stdout_logfile"`
	StderrLogFile string `xmlrpc:"stderr_logfile"`
	Pid           int64  `xmlrpc:"pid"`
}

type RunCode

type RunCode int
const (
	STATE_SHUTDOWN   RunCode = iota - 1 // -1: In process of shutting down.
	STATE_RESTARTING                    //  0: In the process of restarting.
	STATE_RUNNING                       //  1: Is working normally.
	STATE_FATAL                         //  2: Has experienced a serious error.
)

type State

type State struct {
	Code RunCode `xmlrpc:"statecode"`
	Name string  `xmlrpc:"statename"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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