Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) AddProcessGroup(name string) error
- func (c *Client) ClearAllProcessLogs() error
- func (c *Client) ClearLog() error
- func (c *Client) ClearProcessLogs(name string) error
- func (c *Client) GetAPIVersion() (string, error)
- func (c *Client) GetAllProcessInfo() ([]ProcessInfo, error)
- func (c *Client) GetIdentification() (string, error)
- func (c *Client) GetPID() (int, error)
- func (c *Client) GetProcessInfo(name string) (*ProcessInfo, error)
- func (c *Client) GetState() (State, error)
- func (c *Client) GetSupervisorVersion() (string, error)
- func (c *Client) ReadLog(offset int, length int) (string, error)
- func (c *Client) ReadProcessStderrLog(name string, offset int, length int) (string, error)
- func (c *Client) ReadProcessStdoutLog(name string, offset int, length int) (string, error)
- func (c *Client) ReloadConfig() ([]string, []string, []string, error)
- func (c *Client) RemoveProcessGroup(name string) error
- func (c *Client) Restart() error
- func (c *Client) SendProcessStdin(name string, chars string) error
- func (c *Client) SendRemoteCommEvent(typ, data interface{}) error
- func (c *Client) Shutdown() error
- func (c *Client) SignalAllProcesses(signal syscall.Signal) ([]ProcessInfo, error)
- func (c *Client) SignalProcess(name string, signal syscall.Signal) error
- func (c *Client) StartAllProcesses(wait bool) ([]ProcessInfo, error)
- func (c *Client) StartProcess(name string, wait bool) error
- func (c *Client) StartProcessGroup(name string, wait bool) ([]ProcessInfo, error)
- func (c *Client) StopAllProcesses(wait bool) ([]ProcessInfo, error)
- func (c *Client) StopProcess(name string, wait bool) error
- func (c *Client) StopProcessGroup(name string, wait bool) ([]ProcessInfo, error)
- func (c *Client) TailProcessStderrLog(name string, offset int, length int) ([]LogSegment, error)
- func (c *Client) TailProcessStdoutLog(name string, offset int, length int) ([]LogSegment, error)
- func (c *Client) Update() error
- type ClientOption
- type LogSegment
- type ProcessInfo
- type ProcessState
- type State
- type StateCode
- type StateName
Constants ¶
const ( StateCodeFatal StateCode = 2 // Supervisor has experienced a serious error. StateCodeRunning StateCode = 1 // Supervisor is working normally. StateCodeRestarting StateCode = 0 // Supervisor is in the process of restarting. StateCodeShutdown StateCode = -1 // Supervisor is in the process of shutting down. StateNameFatal StateName = "FATAL" // Supervisor has experienced a serious error. StateNameRunning StateName = "RUNNING" // Supervisor is working normally. StateNameRestarting StateName = "RESTARTING" // Supervisor is in the process of restarting. StateNameShutdown StateName = "SHUTDOWN" // Supervisor is in the process of shutting down. )
Variables ¶
var ( // Will be returned by a few functions not yet fully implemented. FIXMENotImplementedError error // Will be returned if the API endpoint returns false without further explanation. ReturnedFalseError error // Will be returned if the API endpoint returns a reply we don't know how to parse. ReturnedMalformedReply error )
Functions ¶
This section is empty.
Types ¶
type Client ¶
func NewClient ¶
func NewClient(url string, opts ...ClientOption) (*Client, error)
Get a new client suitable for communicating with a supervisord. url must contain a real url to a supervisord RPC-service.
Url for local supervisord should be http://127.0.0.1:9001/RPC2 by default.
func NewUnixSocketClient ¶
func NewUnixSocketClient(path string, opts ...ClientOption) (*Client, error)
NewUnixSocketClient returns a new client which connects to supervisord though a local unix socket
func (*Client) AddProcessGroup ¶
Update the config for a running process from config file.
func (*Client) ClearAllProcessLogs ¶
Clear all process log files.
func (*Client) ClearProcessLogs ¶
Clear the stdout and stderr logs for the process name and reopen them.
func (*Client) GetAPIVersion ¶
Return the version of the RPC API used by supervisord.
This API is versioned separately from Supervisor itself. The API version returned by getAPIVersion only changes when the API changes. Its purpose is to help the client identify with which version of the Supervisor API it is communicating.
When writing software that communicates with this API, it is highly recommended that you first test the API version for compatibility before making method calls.
func (*Client) GetAllProcessInfo ¶
func (c *Client) GetAllProcessInfo() ([]ProcessInfo, error)
Get info about all processes.
func (*Client) GetIdentification ¶
Return identifiying string of the supervisord instance.
This method allows the client to identify with which Supervisor instance it is communicating in the case of environments where multiple Supervisors may be running.
The identification is a string that must be set in Supervisor’s configuration file. This method simply returns that value back to the client.
func (*Client) GetProcessInfo ¶
func (c *Client) GetProcessInfo(name string) (*ProcessInfo, error)
Get info about a process named name.
func (*Client) GetState ¶
Return current state of supervisord as a struct.
This is an internal value maintained by Supervisor that determines what Supervisor believes to be its current operational state.
Some method calls can alter the current state of the Supervisor. For example, calling the Shutdown() while the station is in the StateCodeRunning state places the Supervisor in the StateCodeShutdown state while it is shutting down.
func (*Client) GetSupervisorVersion ¶
Return the version of the supervisor package in use by supervisord.
func (*Client) ReadLog ¶
Read length bytes from the main log starting at offset.
It can either return the entire log, a number of characters from the tail of the log, or a part of the log specified by the offset and length parameters.
func (*Client) ReadProcessStderrLog ¶
Read length bytes from name’s stderr log starting at offset.
func (*Client) ReadProcessStdoutLog ¶
Read length bytes from name’s stdout log starting at offset.
func (*Client) ReloadConfig ¶
Reload supervisord configuration.
This will not change, start or stop any running processes. It will only read new configuration. See Update() for an all-in-one solution.
func (*Client) RemoveProcessGroup ¶
Remove a stopped process from the active configuration.
func (*Client) Restart ¶
Restart the supervisor process.
This method soft restarts the Supervisor daemon. If any processes are running, they are automatically killed without warning. Note that the actual UNIX process for Supervisor cannot restart; only Supervisor’s main program loop. This has the effect of resetting the internal states of Supervisor.
Unlike most other methods, if Supervisor is in the StateCodeFatal state, this method will still function.
func (*Client) SendProcessStdin ¶
Send a string to the stdin of the process name. If the process’s stdin cannot accept input (e.g. it was closed by the child process), return non-nil error.
func (*Client) SendRemoteCommEvent ¶
This is not implemented yet.
func (*Client) Shutdown ¶
Shut down the supervisor process.
This method shuts down the Supervisor daemon. If any processes are running, they are automatically killed without warning.
Unlike most other methods, if Supervisor is in the StateCodeFatal state, this method will still function.
func (*Client) SignalAllProcesses ¶
func (c *Client) SignalAllProcesses(signal syscall.Signal) ([]ProcessInfo, error)
SignalAllProcesses sends a signal to all processes in the process list Requires supervisord >= 3.2.0 http://supervisord.org/changes.html#id6
func (*Client) SignalProcess ¶
SignalProcess sends a signal to a process name: Name of the process to signal (or ‘group:name’) signal: Signal to send Requires supervisord >= 3.2.0 http://supervisord.org/changes.html#id6
func (*Client) StartAllProcesses ¶
func (c *Client) StartAllProcesses(wait bool) ([]ProcessInfo, error)
Start all processes listed in the configuration file.
Set wait to true if the call should wait for completion before returning.
func (*Client) StartProcess ¶
Start a process.
func (*Client) StartProcessGroup ¶
func (c *Client) StartProcessGroup(name string, wait bool) ([]ProcessInfo, error)
Start all processes in the group named name.
Set wait to true if the call should wait for completion before returning.
func (*Client) StopAllProcesses ¶
func (c *Client) StopAllProcesses(wait bool) ([]ProcessInfo, error)
Stop all processes in the process list.
Set wait to true if the call should wait for completion before returning.
func (*Client) StopProcess ¶
Stop a process named by name.
Set wait to true if the call should wait for completion before returning.
func (*Client) StopProcessGroup ¶
func (c *Client) StopProcessGroup(name string, wait bool) ([]ProcessInfo, error)
Stop all processes in the process group named name.
Set wait to true if the call should wait for completion before returning.
func (*Client) TailProcessStderrLog ¶
This is not implemented yet.
func (*Client) TailProcessStdoutLog ¶
This is not implemented yet.
type ClientOption ¶
type ClientOption func(*options)
ClientOption is used to customize the client.
func WithAuthentication ¶
func WithAuthentication(username, password string) ClientOption
WithAuthentication sets the username and password to use when authenticating against the server.
type LogSegment ¶
type LogSegment struct { Payload string `xmlrpc:"string"` Offset int `xmlrpc:"offset"` Overflow bool `xmlrpc:"overflow"` }
A LogSegment represents a "tail" of a log
type ProcessInfo ¶
type ProcessInfo struct { Name string `xmlrpc:"name"` // Name of the process Group string `xmlrpc:"group"` // Name of the process’ group Start int `xmlrpc:"start"` // UNIX timestamp of when the process was started Stop int `xmlrpc:"stop"` // UNIX timestamp of when the process last ended, or 0 if the process has never been stopped Now int `xmlrpc:"now"` // UNIX timestamp of the current time, which can be used to calculate process up-time. State ProcessState `xmlrpc:"state"` // State code, see ProcessState. StateName string `xmlrpc:"statename"` // String description of state SpawnErr string `xmlrpc:"spawnerr"` // Description of error that occurred during spawn, or empty string if none ExitStatus int `xmlrpc:"exitstatus"` // Exit status (errorlevel) of process, or 0 if the process is still running StdoutLogfile string `xmlrpc:"stdout_logfile"` // Absolute path and filename to the STDOUT logfile StderrLogfile string `xmlrpc:"stderr_logfile"` // Absolute path and filename to the STDOUT logfile Pid int `xmlrpc:"pid"` // UNIX process ID (PID) of the process, or 0 if the process is not running }
A structure containing data about a process.
type ProcessState ¶
type ProcessState int
A process controlled by supervisord will be in one of the below states at any given time. You may see these state names in various user interface elements in clients.
const ( StateStopped ProcessState = 0 // The process has been stopped due to a stop request or has never been started StateStarting ProcessState = 10 // The process is starting due to a start request StateRunning ProcessState = 20 // The process is running StateBackoff ProcessState = 30 // The process entered the StateStarting state but subsequently exited too quickly to move to the StateRunning state StateStopping ProcessState = 40 // The process is stopping due to a stop request StateExited ProcessState = 100 // The process exited from the StateRunning state (expectedly or unexpectedly) StateFatal ProcessState = 200 // The process could not be started successfully StateUnknown ProcessState = 1000 // The process is in an unknown state (supervisord programming error) )