Documentation
¶
Index ¶
- Constants
- Variables
- func AddHandle(handler Handler)
- func Aggregate(op, key string, value float64, id string, tags ...Tag)
- func BadRequestError(cause interface{}) error
- func Error(code uint32, cause interface{}) error
- func InternalError(cause interface{}) error
- func Jobs() map[string]Job
- func Kill(cmdID string) error
- func Killall()
- func MustArguments(args interface{}) *json.RawMessage
- func New()
- func NotAcceptableError(cause interface{}) error
- func NotFoundError(cause interface{}) error
- func PreconditionFailedError(cause interface{}) error
- func Register(name string, factory ProcessFactory)
- func RegisterBuiltIn(name string, runnable Runnable)
- func RegisterBuiltInWithCtx(name string, runnable RunnableWithCtx)
- func RegisterExtension(cmd string, exe string, workdir string, cmdargs []string, ...) error
- func RunSlice(slice settings.StartupSlice)
- func ServiceUnavailableError(cause interface{}) error
- func SetUnprivileged()
- func Start()
- type Channel
- type Command
- type ContainerCommandArguments
- type ContainerProcess
- type Context
- type DelayHook
- type ExitHook
- type GetPID
- type Handler
- type Job
- type JobFlags
- type JobResult
- type JobState
- type M
- type MatchHook
- type MessageHandler
- type NOOPHook
- type PIDHook
- type PIDTable
- type PreHandler
- type Process
- type ProcessFactory
- type ProcessStats
- type Queue
- type ResultHandler
- type RunError
- type Runnable
- type RunnableWithCtx
- type RunnerHook
- type Signaler
- type Stater
- type StatsHandler
- type StreamHook
- type Streams
- type SystemCommandArguments
- type Tag
- type Tags
Constants ¶
const ( StandardStreamBufferSize = 100 //buffer size for each of stdout and stderr GenericStreamBufferSize = 10 //we only keep last 100 message of all types. )
const ( AggreagteAverage = "A" AggreagteDifference = "D" )
const (
CommandSystem = "core.system"
)
Variables ¶
Functions ¶
func BadRequestError ¶ added in v1.2.0
func BadRequestError(cause interface{}) error
func InternalError ¶ added in v1.2.0
func InternalError(cause interface{}) error
func MustArguments ¶ added in v1.2.0
func MustArguments(args interface{}) *json.RawMessage
func NotAcceptableError ¶ added in v1.2.0
func NotAcceptableError(cause interface{}) error
func NotFoundError ¶ added in v1.2.0
func NotFoundError(cause interface{}) error
func PreconditionFailedError ¶ added in v1.2.0
func PreconditionFailedError(cause interface{}) error
func Register ¶ added in v1.2.0
func Register(name string, factory ProcessFactory)
func RegisterBuiltIn ¶ added in v1.2.0
func RegisterBuiltInWithCtx ¶ added in v1.2.0
func RegisterBuiltInWithCtx(name string, runnable RunnableWithCtx)
func RegisterExtension ¶ added in v1.2.0
func RegisterExtension(cmd string, exe string, workdir string, cmdargs []string, env map[string]string) error
RegisterExtension registers a new command (extension) so it can be executed via commands
func RunSlice ¶ added in v1.2.0
func RunSlice(slice settings.StartupSlice)
RunSlice runs a slice of processes honoring dependencies. It won't just start in order, but will also make sure a service won't start until it's dependencies are running.
func ServiceUnavailableError ¶ added in v1.2.0
func ServiceUnavailableError(cause interface{}) error
func SetUnprivileged ¶ added in v1.2.0
func SetUnprivileged()
Types ¶
type Channel ¶ added in v1.2.0
type Channel interface {
io.ReadWriteCloser
}
type Command ¶ added in v1.2.0
type Command struct {
ID string `json:"id"`
Command string `json:"command"`
Arguments *json.RawMessage `json:"arguments"`
Queue string `json:"queue"`
StatsInterval int `json:"stats_interval,omitempty"`
MaxTime int `json:"max_time,omitempty"`
MaxRestart int `json:"max_restart,omitempty"`
RecurringPeriod int `json:"recurring_period,omitempty"`
Stream bool `json:"stream"`
LogLevels []int `json:"log_levels,omitempty"`
Tags Tags `json:"tags"`
Flags JobFlags `json:"-"`
}
Cmd is an executable command
type ContainerCommandArguments ¶ added in v1.2.0
type ContainerCommandArguments struct {
Name string `json:"name"`
Dir string `json:"dir"`
Args []string `json:"args"`
Env map[string]string `json:"env"`
HostNetwork bool `json:"host_network"`
Chroot string `json:"chroot"`
Log string `json:"log"`
}
func (*ContainerCommandArguments) String ¶ added in v1.2.0
func (c *ContainerCommandArguments) String() string
type ContainerProcess ¶ added in v1.2.0
type Context ¶ added in v1.2.0
type Context struct {
Command *Command
// contains filtered or unexported fields
}
type DelayHook ¶
type Job ¶ added in v1.2.0
type Job interface {
Command() *Command
Signal(sig syscall.Signal) error
Process() Process
Wait() *JobResult
StartTime() int64
Subscribe(stream.MessageHandler)
// contains filtered or unexported methods
}
func Run ¶ added in v1.2.0
func Run(cmd *Command, hooks ...RunnerHook) (Job, error)
Run runs a command immediately (no pre-processors)
func RunFactory ¶ added in v1.2.0
func RunFactory(cmd *Command, factory ProcessFactory, hooks ...RunnerHook) (Job, error)
type JobFlags ¶ added in v1.2.0
type JobFlags struct {
Protected bool
NoOutput bool
NoSetPGID bool //set new process group id for job
}
JobFlags to control job behavior but only from the internal API\ Clients cant set the JobFlags, unlike the other public flags on the Command struct body.
type JobResult ¶ added in v1.2.0
type JobResult struct {
ID string `json:"id"`
Command string `json:"command"`
Data string `json:"data"`
Streams Streams `json:"streams,omitempty"`
Critical string `json:"critical,omitempty"`
Level uint16 `json:"level"`
State JobState `json:"state"`
Code uint32 `json:"code"`
StartTime int64 `json:"starttime"`
Time int64 `json:"time"`
Tags Tags `json:"tags"`
Container uint64 `json:"container"`
}
JobResult represents a result of a job
func NewJobResult ¶ added in v1.2.0
NewJobResult creates a new job result from command
type JobState ¶ added in v1.2.0
type JobState string
const ( //StateSuccess successs exit status StateSuccess JobState = "SUCCESS" //StateError error exist status StateError JobState = "ERROR" //StateTimeout timeout exit status StateTimeout JobState = "TIMEOUT" //StateKilled killed exit status StateKilled JobState = "KILLED" //StateUnknownCmd unknown cmd exit status StateUnknownCmd JobState = "UNKNOWN_CMD" //StateDuplicateID dublicate id exit status StateDuplicateID JobState = "DUPILICATE_ID" )
type MatchHook ¶
type MessageHandler ¶
type PIDTable ¶ added in v1.2.0
type PIDTable interface {
//PIDTable atomic registration of PID. MUST grantee that that no wait4 will happen
//on any of the child process until the register operation is done.
RegisterPID(g GetPID) error
WaitPID(pid int) syscall.WaitStatus
}
type PreHandler ¶ added in v1.2.0
type PreHandler interface {
Pre(cmd *Command)
}
type Process ¶ added in v1.2.0
Process interface
func NewContainerProcess ¶ added in v1.2.0
func NewSystemProcess ¶ added in v1.2.0
type ProcessFactory ¶ added in v1.2.0
func GetProcessFactory ¶
func GetProcessFactory(cmd *Command) ProcessFactory
NewProcess creates a new process from a command
type ProcessStats ¶ added in v1.2.0
type ProcessStats struct {
CPU float64 `json:"cpu"`
RSS uint64 `json:"rss"`
VMS uint64 `json:"vms"`
Swap uint64 `json:"swap"`
Debug string `json:"debug,ommitempty"`
}
ProcessStats holds process cpu and memory usage
type Queue ¶ added in v1.2.0
type Queue struct {
// contains filtered or unexported fields
}
* Queue is used for sequential cmds exectuions
type ResultHandler ¶
type Runnable ¶ added in v1.2.0
Runnable represents a runnable built in function that can be managed by the process manager.
type RunnableWithCtx ¶ added in v1.2.0
type RunnerHook ¶
type Stater ¶ added in v1.2.0
type Stater interface {
Process
Stats() *ProcessStats
}
type StatsHandler ¶ added in v0.11.0
type StreamHook ¶ added in v1.2.0
func (*StreamHook) Message ¶ added in v1.2.0
func (h *StreamHook) Message(msg *stream.Message)
type SystemCommandArguments ¶ added in v1.2.0
type SystemCommandArguments struct {
Name string `json:"name"`
Dir string `json:"dir"`
Args []string `json:"args"`
Env map[string]string `json:"env"`
StdIn string `json:"stdin"`
}
func (*SystemCommandArguments) String ¶ added in v1.2.0
func (s *SystemCommandArguments) String() string