Documentation
¶
Index ¶
- func AbsSince(t time.Time) string
- func Fork() (int, error)
- func GetJSON(spath, path string, target interface{}) error
- func GetSdir() string
- func GetUserSdir() (string, error)
- func Green(s string) string
- func NewLogger(cfg *Config, quit chan struct{}) *log.Logger
- func NewProcess(cfg *Config) *process
- func NewStderrLogger(cfg *Config) *log.Logger
- func Red(s string) string
- func Supervise(d *Daemon) error
- func Yellow(s string) string
- type Config
- type Control
- type Controller
- func (c *Controller) FindServices(dir string) ([]*ServiceStatus, error)
- func (c *Controller) GetStatus(socket string) (*Status, error)
- func (c *Controller) PurgeServices(dir string) error
- func (c *Controller) Run(command string) ([]byte, error)
- func (c *Controller) SendSignal(socket, signal string) (*SignalResponse, error)
- type Daemon
- func (d *Daemon) HandleSignal(w http.ResponseWriter, r *http.Request)
- func (d *Daemon) HandleStatus(w http.ResponseWriter, r *http.Request)
- func (d *Daemon) IsRunning(pid int) bool
- func (d *Daemon) Listen() (err error)
- func (d *Daemon) ReadPidFile(pidfile string) (int, error)
- func (d *Daemon) Run(p Process) (*process, error)
- func (d *Daemon) WatchPid(pid int, ch chan<- error)
- func (d *Daemon) WritePid(file string, pid int) error
- type Flags
- type Log
- type LogWriter
- type Logger
- type Parse
- type Parser
- type Pid
- type Process
- type ScanDir
- type ServiceStatus
- type SignalResponse
- type Status
- type Supervisor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSdir ¶
func GetSdir() string
GetSdir return the main supervise directory, defaults to /var/run/immortal
func NewStderrLogger ¶
NewStderrLogger return Logger instance
Types ¶
type Config ¶
type Config struct { Cmd string `yaml:"cmd" json:"cmd"` Cwd string `yaml:",omitempty" json:",omitempty"` Env map[string]string `yaml:",omitempty" json:",omitempty"` Log Log `yaml:",omitempty" json:",omitempty"` Stderr Log `yaml:",omitempty" json:",omitempty"` Logger string `yaml:",omitempty" json:",omitempty"` Require []string `yaml:",omitempty"` RequireCmd string `yaml:"require_cmd,omitempty"` PostExit string `yaml:"post_exit,omitempty"` User string `yaml:",omitempty" json:",omitempty"` Wait uint `yaml:",omitempty"` Retries int `yaml:",omitempty"` Pid `yaml:",omitempty" json:",omitempty"` // contains filtered or unexported fields }
Config yaml/command line configuration
type Control ¶
type Control interface { GetStatus(socket string) (*Status, error) SendSignal(socket, signal string) (*SignalResponse, error) FindServices(dir string) ([]*ServiceStatus, error) PurgeServices(dir string) error Run(command string) ([]byte, error) }
Control interface
type Controller ¶
type Controller struct{}
Controller implements Control
func (*Controller) FindServices ¶
func (c *Controller) FindServices(dir string) ([]*ServiceStatus, error)
FindServices return [name, socket path] of service
func (*Controller) GetStatus ¶
func (c *Controller) GetStatus(socket string) (*Status, error)
GetStatus returns service status in json format
func (*Controller) PurgeServices ¶
func (c *Controller) PurgeServices(dir string) error
PurgeServices remove unused service directory
func (*Controller) Run ¶
func (c *Controller) Run(command string) ([]byte, error)
Run executes a command and print combinedOutput
func (*Controller) SendSignal ¶
func (c *Controller) SendSignal(socket, signal string) (*SignalResponse, error)
SendSignal send signal to process
type Daemon ¶
Daemon struct
func (*Daemon) HandleSignal ¶
func (d *Daemon) HandleSignal(w http.ResponseWriter, r *http.Request)
HandleSignal send signals to the current process
func (*Daemon) HandleStatus ¶
func (d *Daemon) HandleStatus(w http.ResponseWriter, r *http.Request)
HandleStatus return process status
func (*Daemon) ReadPidFile ¶
ReadPidFile read pid from file if error returns pid 0
type Flags ¶
type Flags struct { CheckConfig bool ChildPid string Command string Configfile string Ctl string Envdir string FollowPid string Logfile string Logger string Nodaemon bool ParentPid string Retries int User string Version bool Wait uint Wrkdir string }
Flags available command flags
type Log ¶
type Log struct { File string `yaml:",omitempty"` Age int `yaml:",omitempty"` Num int `yaml:",omitempty"` Size int `yaml:",omitempty"` Timestamp bool `yaml:",omitempty"` }
Log struct run.yml
type LogWriter ¶
type LogWriter struct {
// contains filtered or unexported fields
}
LogWriter implements Logger
type Parser ¶
type Parser interface { Parse(fs *flag.FlagSet) (*Flags, error) // contains filtered or unexported methods }
Parser interface
type Pid ¶
type Pid struct { Follow string `yaml:",omitempty"` Parent string `yaml:",omitempty"` Child string `yaml:",omitempty"` }
Pid struct run.yml
type Process ¶
type Process interface { Kill() error Pid() int Signal(sig syscall.Signal) error Start() (*process, error) GetProcess() *process }
Process interface
type ScanDir ¶
type ScanDir struct {
// contains filtered or unexported fields
}
ScanDir struct
type ServiceStatus ¶
type ServiceStatus struct { Name string Socket string Status *Status SignalResponse *SignalResponse }
ServiceStatus struct
type SignalResponse ¶
type SignalResponse struct {
Err string
}
SignalResponse struct to return the error in json format
type Status ¶
type Status struct { Pid int `json:"pid"` Up string `json:"up,omitempty"` Down string `json:"down,omitempty"` Cmd string `json:"cmd"` Fpid bool `json:"fpid"` Count int `json:"count"` Status string `json:"status,omitempty"` }
Status struct
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor for the process
func (*Supervisor) FollowPid ¶
func (s *Supervisor) FollowPid(err error)
FollowPid check if process still up and running if it is, follow the pid, monitor the existing pid created by the process instead of creating another process
func (*Supervisor) Terminate ¶
func (s *Supervisor) Terminate(err error) bool
Terminate handle process termination