supervisord_main

package module
v0.0.0-...-60f0a74 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SupervisorVersion the version of supervisor
	SupervisorVersion = "3.0"
)
View Source
const VERSION = "v0.7.3"

VERSION the version of supervisor

Variables

View Source
var HTTP http.FileSystem = http.Dir("./webgui")

HTTP auto generated

Functions

func Daemonize

func Daemonize(logfile string, proc func())

Daemonize run this process in daemon mode

func GenTemplate

func GenTemplate(writer io.Writer) error

GenTemplate generate the template

func RealMain

func RealMain()

func ReapZombie

func ReapZombie()

ReapZombie reap the zombie child process

Types

type BaseChecker

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

BaseChecker basic implementation of ContentChecker

func NewBaseChecker

func NewBaseChecker(includes []string, timeout int) *BaseChecker

NewBaseChecker creates BaseChecker object

func (*BaseChecker) Check

func (bc *BaseChecker) Check() bool

Check content of the input data

func (*BaseChecker) Write

func (bc *BaseChecker) Write(b []byte) (int, error)

Write data to the checker

type CmdCheckWrapperCommand

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

CmdCheckWrapperCommand A wrapper can be used to check whether number of parameters is valid or not

func (*CmdCheckWrapperCommand) Execute

func (wc *CmdCheckWrapperCommand) Execute(args []string) error

Execute check if the number of arguments is ok

type ConfApi

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

func NewConfApi

func NewConfApi(supervisor *Supervisor) *ConfApi

NewLogtail creates a Logtail object

func (*ConfApi) CreateHandler

func (ca *ConfApi) CreateHandler() http.Handler

CreateHandler creates http handlers to process the program stdout and stderr through http interface

type ContentChecker

type ContentChecker interface {
	Check() bool
}

ContentChecker defines check interface

type CtlCommand

type CtlCommand struct {
	ServerURL string `short:"s" long:"serverurl" description:"URL on which supervisord server is listening"`
	User      string `short:"u" long:"user" description:"the user name"`
	Password  string `short:"P" long:"password" description:"the password"`
	Verbose   bool   `short:"v" long:"verbose" description:"Show verbose debug information"`
}

CtlCommand the entry of ctl command

func (*CtlCommand) Execute

func (x *CtlCommand) Execute(args []string) error

Execute implements flags.Commander interface to execute the control commands

type HTTPChecker

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

HTTPChecker implements the ContentChecker by HTTP protocol

func NewHTTPChecker

func NewHTTPChecker(url string, timeout int) *HTTPChecker

NewHTTPChecker creates HTTPChecker object

func (*HTTPChecker) Check

func (hc *HTTPChecker) Check() bool

Check content of HTTP response

type InitTemplateCommand

type InitTemplateCommand struct {
	OutFile string `short:"o" long:"output" description:"the output file name" required:"true"`
}

InitTemplateCommand implements flags.Commander interface

func (*InitTemplateCommand) Execute

func (x *InitTemplateCommand) Execute(args []string) error

Execute execute the init command

type LogReadInfo

type LogReadInfo struct {
	Offset int // the log offset
	Length int // the length of log to read
}

LogReadInfo the input argument to read the log of supervisor

type Logtail

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

Logtail tails the process log through http interface

func NewLogtail

func NewLogtail(supervisor *Supervisor) *Logtail

NewLogtail creates a Logtail object

func (*Logtail) CreateHandler

func (lt *Logtail) CreateHandler() http.Handler

CreateHandler creates http handlers to process the program stdout and stderr through http interface

type LogtailCommand

type LogtailCommand struct {
}

LogtailCommand tail the stdout/stderr log of program through http interface

func (*LogtailCommand) Execute

func (lc *LogtailCommand) Execute(args []string) error

Execute tail the stdout/stderr of a program through http interface

type Options

type Options struct {
	Configuration string `short:"c" long:"configuration" description:"the configuration file"`
	Daemon        bool   `short:"d" long:"daemon" description:"run as daemon"`
	EnvFile       string `long:"env-file" description:"the environment file"`
}

Options the command line options

type PidCommand

type PidCommand struct {
}

PidCommand get the pid of program

func (*PidCommand) Execute

func (pc *PidCommand) Execute(args []string) error

Execute get the pid of program

type ProcessLogReadInfo

type ProcessLogReadInfo struct {
	Name   string // the program name
	Offset int    // the offset of the program log
	Length int    // the length of log to read
}

ProcessLogReadInfo the input argument to read the log of program

type ProcessStdin

type ProcessStdin struct {
	Name  string // program name
	Chars string // inputs from client
}

ProcessStdin process stdin from client

type ProcessTailLog

type ProcessTailLog struct {
	LogData  string
	Offset   int64
	Overflow bool
}

ProcessTailLog the output of tail the program log

type RPCTaskResult

type RPCTaskResult struct {
	Name        string `xml:"name"`        // the program name
	Group       string `xml:"group"`       // the group of the program
	Status      int    `xml:"status"`      // the status of the program
	Description string `xml:"description"` // the description of program
}

RPCTaskResult result of some remote commands

type ReloadCommand

type ReloadCommand struct {
}

ReloadCommand reload all the programs

func (*ReloadCommand) Execute

func (rc *ReloadCommand) Execute(args []string) error

Execute stop the running programs and reload the supervisor configuration

type RemoteCommEvent

type RemoteCommEvent struct {
	Type string // the event type
	Data string // the data of event
}

RemoteCommEvent remove communication event from client side

type RestartCommand

type RestartCommand struct {
}

RestartCommand restart the given program

func (*RestartCommand) Execute

func (rc *RestartCommand) Execute(args []string) error

Execute restart the programs

type ScriptChecker

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

ScriptChecker implements ContentChecker by calling external script

func NewScriptChecker

func NewScriptChecker(args []string) *ScriptChecker

NewScriptChecker creates ScriptChecker object

func (*ScriptChecker) Check

func (sc *ScriptChecker) Check() bool

Check return code of the script. If return code is 0, check is successful

type ServiceCommand

type ServiceCommand struct {
}

ServiceCommand install/uninstall/start/stop supervisord service

func (ServiceCommand) Execute

func (sc ServiceCommand) Execute(args []string) error

Execute implement Execute() method defined in flags.Commander interface, executes the given command

type ShutdownCommand

type ShutdownCommand struct {
}

ShutdownCommand shutdown the supervisor

func (*ShutdownCommand) Execute

func (sc *ShutdownCommand) Execute(args []string) error

Execute shutdown the supervisor

type SignalCommand

type SignalCommand struct {
}

SignalCommand send signal of program

func (*SignalCommand) Execute

func (rc *SignalCommand) Execute(args []string) error

Execute send signal to program

type StartCommand

type StartCommand struct {
}

StartCommand start the given program

func (*StartCommand) Execute

func (sc *StartCommand) Execute(args []string) error

Execute start the given programs

type StartProcessArgs

type StartProcessArgs struct {
	Name string // program name
	Wait bool   `default:"true"` // Wait the program starting finished
}

StartProcessArgs arguments for starting a process

type StateInfo

type StateInfo struct {
	Statecode int    `xml:"statecode"`
	Statename string `xml:"statename"`
}

StateInfo describe the state of supervisor

type StatusCommand

type StatusCommand struct {
}

StatusCommand get the status of all supervisor managed programs

func (*StatusCommand) Execute

func (sc *StatusCommand) Execute(args []string) error

Execute implements flags.Commander interface to get status of program

type StopCommand

type StopCommand struct {
}

StopCommand stop the given program

func (*StopCommand) Execute

func (sc *StopCommand) Execute(args []string) error

Execute stop the given programs

type Supervisor

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

Supervisor manage all the processes defined in the supervisor configuration file. All the supervisor public interface is defined in this class

func NewSupervisor

func NewSupervisor(configFile string) *Supervisor

NewSupervisor create a Supervisor object with supervisor configuration file

func (*Supervisor) AddProcessGroup

func (s *Supervisor) AddProcessGroup(r *http.Request, args *struct{ Name string }, reply *struct{ Success bool }) error

AddProcessGroup adds a process group to the supervisor

func (*Supervisor) ClearAllProcessLogs

func (s *Supervisor) ClearAllProcessLogs(r *http.Request, args *struct{}, reply *struct{ RPCTaskResults []RPCTaskResult }) error

ClearAllProcessLogs clears logs of all programs

func (*Supervisor) ClearLog

func (s *Supervisor) ClearLog(r *http.Request, args *struct{}, reply *struct{ Ret bool }) error

ClearLog clear the supervisor log

func (*Supervisor) ClearProcessLogs

func (s *Supervisor) ClearProcessLogs(r *http.Request, args *struct{ Name string }, reply *struct{ Success bool }) error

ClearProcessLogs clears log of given program

func (*Supervisor) GetAllProcessInfo

func (s *Supervisor) GetAllProcessInfo(r *http.Request, args *struct{}, reply *struct{ AllProcessInfo []types.ProcessInfo }) error

GetAllProcessInfo get all the program information managed by supervisor

func (*Supervisor) GetConfig

func (s *Supervisor) GetConfig() *config.Config

GetConfig get the loaded supervisor configuration

func (*Supervisor) GetIdentification

func (s *Supervisor) GetIdentification(r *http.Request, args *struct{}, reply *struct{ ID string }) error

GetIdentification get the supervisor identifier configured in the file

func (*Supervisor) GetManager

func (s *Supervisor) GetManager() *process.Manager

GetManager get the Manager object created by supervisor

func (*Supervisor) GetPID

func (s *Supervisor) GetPID(r *http.Request, args *struct{}, reply *struct{ Pid int }) error

GetPID get the pid of supervisor

func (*Supervisor) GetProcessInfo

func (s *Supervisor) GetProcessInfo(r *http.Request, args *struct{ Name string }, reply *struct{ ProcInfo types.ProcessInfo }) error

GetProcessInfo get the process information of one program

func (*Supervisor) GetPrograms

func (s *Supervisor) GetPrograms() []string

GetPrograms Get all the name of programs

Return the name of all the programs

func (*Supervisor) GetState

func (s *Supervisor) GetState(r *http.Request, args *struct{}, reply *struct{ StateInfo StateInfo }) error

GetState get the state of supervisor

func (*Supervisor) GetSupervisorID

func (s *Supervisor) GetSupervisorID() string

GetSupervisorID get the supervisor identifier from configuration file

func (*Supervisor) GetSupervisorVersion

func (s *Supervisor) GetSupervisorVersion(r *http.Request, args *struct{}, reply *struct{ Version string }) error

GetSupervisorVersion get the supervisor version

func (*Supervisor) GetVersion

func (s *Supervisor) GetVersion(r *http.Request, args *struct{}, reply *struct{ Version string }) error

GetVersion get the version of supervisor

func (*Supervisor) IsRestarting

func (s *Supervisor) IsRestarting() bool

IsRestarting check if supervisor is in restarting state

func (*Supervisor) ReadLog

func (s *Supervisor) ReadLog(r *http.Request, args *LogReadInfo, reply *struct{ Log string }) error

ReadLog read the log of supervisor

func (*Supervisor) ReadProcessStderrLog

func (s *Supervisor) ReadProcessStderrLog(r *http.Request, args *ProcessLogReadInfo, reply *struct{ LogData string }) error

ReadProcessStderrLog reads stderr log of given program

func (*Supervisor) ReadProcessStdoutLog

func (s *Supervisor) ReadProcessStdoutLog(r *http.Request, args *ProcessLogReadInfo, reply *struct{ LogData string }) error

ReadProcessStdoutLog reads stdout of given program

func (*Supervisor) Reload

func (s *Supervisor) Reload(restart bool) (addedGroup []string, changedGroup []string, removedGroup []string, err error)

Reload supervisord configuration.

func (*Supervisor) ReloadConfig

func (s *Supervisor) ReloadConfig(r *http.Request, args *struct{}, reply *types.ReloadConfigResult) error

ReloadConfig reloads supervisord configuration file

func (*Supervisor) RemoveProcessGroup

func (s *Supervisor) RemoveProcessGroup(r *http.Request, args *struct{ Name string }, reply *struct{ Success bool }) error

RemoveProcessGroup removes a process group from the supervisor

func (*Supervisor) Restart

func (s *Supervisor) Restart(r *http.Request, args *struct{}, reply *struct{ Ret bool }) error

Restart the supervisor

func (*Supervisor) SendProcessStdin

func (s *Supervisor) SendProcessStdin(r *http.Request, args *ProcessStdin, reply *struct{ Success bool }) error

SendProcessStdin send data to program through stdin

func (*Supervisor) SendRemoteCommEvent

func (s *Supervisor) SendRemoteCommEvent(r *http.Request, args *RemoteCommEvent, reply *struct{ Success bool }) error

SendRemoteCommEvent emit a remote communication event

func (*Supervisor) Shutdown

func (s *Supervisor) Shutdown(r *http.Request, args *struct{}, reply *struct{ Ret bool }) error

Shutdown the supervisor

func (*Supervisor) SignalAllProcesses

func (s *Supervisor) SignalAllProcesses(r *http.Request, args *types.ProcessSignal, reply *struct{ AllProcessInfo []types.ProcessInfo }) error

SignalAllProcesses send signal to all the processes in the supervisor

func (*Supervisor) SignalProcess

func (s *Supervisor) SignalProcess(r *http.Request, args *types.ProcessSignal, reply *struct{ Success bool }) error

SignalProcess send a signal to running program

func (*Supervisor) SignalProcessGroup

func (s *Supervisor) SignalProcessGroup(r *http.Request, args *types.ProcessSignal, reply *struct{ AllProcessInfo []types.ProcessInfo }) error

SignalProcessGroup send signal to all processes in one group

func (*Supervisor) StartAllProcesses

func (s *Supervisor) StartAllProcesses(r *http.Request, args *struct {
	Wait bool `default:"true"`
}, reply *struct{ RPCTaskResults []RPCTaskResult }) error

StartAllProcesses start all the programs

func (*Supervisor) StartProcess

func (s *Supervisor) StartProcess(r *http.Request, args *StartProcessArgs, reply *struct{ Success bool }) error

StartProcess start the given program

func (*Supervisor) StartProcessGroup

func (s *Supervisor) StartProcessGroup(r *http.Request, args *StartProcessArgs, reply *struct{ AllProcessInfo []types.ProcessInfo }) error

StartProcessGroup start all the processes in one group

func (*Supervisor) StopAllProcesses

func (s *Supervisor) StopAllProcesses(r *http.Request, args *struct {
	Wait bool `default:"true"`
}, reply *struct{ RPCTaskResults []RPCTaskResult }) error

StopAllProcesses stop all programs managed by supervisor

func (*Supervisor) StopProcess

func (s *Supervisor) StopProcess(r *http.Request, args *StartProcessArgs, reply *struct{ Success bool }) error

StopProcess stop given program

func (*Supervisor) StopProcessGroup

func (s *Supervisor) StopProcessGroup(r *http.Request, args *StartProcessArgs, reply *struct{ AllProcessInfo []types.ProcessInfo }) error

StopProcessGroup stop all processes in one group

func (*Supervisor) TailProcessStderrLog

func (s *Supervisor) TailProcessStderrLog(r *http.Request, args *ProcessLogReadInfo, reply *ProcessTailLog) error

TailProcessStderrLog tails stderr of the program

func (*Supervisor) TailProcessStdoutLog

func (s *Supervisor) TailProcessStdoutLog(r *http.Request, args *ProcessLogReadInfo, reply *ProcessTailLog) error

TailProcessStdoutLog tails stdout of the program

func (*Supervisor) WaitForExit

func (s *Supervisor) WaitForExit()

WaitForExit waits for supervisord to exit

type SupervisorRestful

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

SupervisorRestful the restful interface to control the programs defined in configuration file

func NewSupervisorRestful

func NewSupervisorRestful(supervisor *Supervisor) *SupervisorRestful

NewSupervisorRestful create a new SupervisorRestful object

func (*SupervisorRestful) CreateProgramHandler

func (sr *SupervisorRestful) CreateProgramHandler() http.Handler

CreateProgramHandler create http handler to process program related restful request

func (*SupervisorRestful) CreateSupervisorHandler

func (sr *SupervisorRestful) CreateSupervisorHandler() http.Handler

CreateSupervisorHandler create http rest interface to control supervisor itself

func (*SupervisorRestful) ListProgram

func (sr *SupervisorRestful) ListProgram(w http.ResponseWriter, req *http.Request)

ListProgram list the status of all the programs

json array to present the status of all programs

func (*SupervisorRestful) ReadStdoutLog

func (sr *SupervisorRestful) ReadStdoutLog(w http.ResponseWriter, req *http.Request)

ReadStdoutLog read the stdout of given program

func (*SupervisorRestful) Reload

func (sr *SupervisorRestful) Reload(w http.ResponseWriter, req *http.Request)

Reload the supervisor configuration file through rest interface

func (*SupervisorRestful) Shutdown

func (sr *SupervisorRestful) Shutdown(w http.ResponseWriter, req *http.Request)

Shutdown the supervisor itself

func (*SupervisorRestful) StartProgram

func (sr *SupervisorRestful) StartProgram(w http.ResponseWriter, req *http.Request)

StartProgram start the given program through restful interface

func (*SupervisorRestful) StartPrograms

func (sr *SupervisorRestful) StartPrograms(w http.ResponseWriter, req *http.Request)

StartPrograms start one or more programs through restful interface

func (*SupervisorRestful) StopProgram

func (sr *SupervisorRestful) StopProgram(w http.ResponseWriter, req *http.Request)

StopProgram stop a program through the restful interface

func (*SupervisorRestful) StopPrograms

func (sr *SupervisorRestful) StopPrograms(w http.ResponseWriter, req *http.Request)

StopPrograms stop programs through the restful interface

type SupervisorWebgui

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

SupervisorWebgui the interface to show a WEBGUI to control the supervisor

func NewSupervisorWebgui

func NewSupervisorWebgui(supervisor *Supervisor) *SupervisorWebgui

NewSupervisorWebgui create a new SupervisorWebgui object

func (*SupervisorWebgui) CreateHandler

func (sw *SupervisorWebgui) CreateHandler() http.Handler

CreateHandler create a http handler to process the request from WEBGUI

type TCPChecker

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

TCPChecker check by TCP protocol

func NewTCPChecker

func NewTCPChecker(host string, port int, includes []string, timeout int) *TCPChecker

NewTCPChecker creates TCPChecker object

func (*TCPChecker) Check

func (tc *TCPChecker) Check() bool

Check if it is ready by reading the tcp data

type VersionCommand

type VersionCommand struct {
}

VersionCommand implement the flags.Commander interface

func (VersionCommand) Execute

func (v VersionCommand) Execute(args []string) error

Execute implement Execute() method defined in flags.Commander interface, executes the given command

type XMLRPC

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

XMLRPC mange the XML RPC servers start XML RPC servers to accept the XML RPC request from client side

func NewXMLRPC

func NewXMLRPC() *XMLRPC

NewXMLRPC create a new XML RPC object

func (*XMLRPC) StartInetHTTPServer

func (p *XMLRPC) StartInetHTTPServer(user string, password string, listenAddr string, s *Supervisor, startedCb func())

StartInetHTTPServer start http server on tcp with path listenAddr. If both user and password are not empty, the user must provide user and password for basic authentication when making an XML RPC request.

func (*XMLRPC) StartUnixHTTPServer

func (p *XMLRPC) StartUnixHTTPServer(user string, password string, listenAddr string, s *Supervisor, startedCb func())

StartUnixHTTPServer start http server on unix domain socket with path listenAddr. If both user and password are not empty, the user must provide user and password for basic authentication when making an XML RPC request.

func (*XMLRPC) Stop

func (p *XMLRPC) Stop()

Stop network listening

Jump to

Keyboard shortcuts

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