daemon

package
v1.1.18 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Zlib Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KStatusRunning = Status(1)
	KStatusClose   = Status(2)
	KStatusExit    = Status(3)
)
View Source
const KMaxGroupCount = 3000

Variables

View Source
var (
	DefConfig       = Config{Config: system.Config{EnableEnv: true, EnableStd: false}}
	DefGRun   *GRun = nil

	CmdNilErr   = errors.New("cmd obj is nil")
	MaxCountErr = errors.New("max count")
	MaxErr      = errors.New("max error")
)

Functions

func Group added in v0.8.3

func Group(group int, args []string, cb ProcessCallback, config Config, opts ...ArgOptionFunc)

Group 守护进程启动一个N[1,2000]子进程, 并循环监视

func Run

func Run(groupId int, args []string, cb ProcessCallback, config Config, opts ...ArgOptionFunc) int

Run 守护进程启动一个子进程, 并循环监视

Types

type ArgOption added in v1.0.66

type ArgOption struct {
	Id   int
	Data interface{} //用户自己定义
	Args []string
	Env  []string
}

type ArgOptionFunc added in v1.0.66

type ArgOptionFunc func(arg *ArgOption)

type Cmd added in v1.1.0

type Cmd struct {
	Cmd  *exec.Cmd
	Err  error
	Data interface{}
}

func Background

func Background(id int, args []string, conf Config, opts ...ArgOptionFunc) (*Cmd, error)

func (*Cmd) WithErr added in v1.1.0

func (c *Cmd) WithErr(err error) *Cmd

type Config

type Config struct {
	system.Config
	MaxCount    int   `json:"maxCount" yaml:"maxCount" xml:"maxCount"`
	MaxError    int   `json:"maxError" yaml:"maxError" xml:"maxError"`
	MinExitTime int64 `json:"minExitTime" yaml:"minExitTime" xml:"minExitTime"`
}

type GRun added in v1.1.17

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

func NewGroup added in v1.1.17

func NewGroup() *GRun

func (*GRun) Add added in v1.1.17

func (g *GRun) Add(id int, it *Item) error

func (*GRun) Exec added in v1.1.17

func (g *GRun) Exec(cb ProcessCallback, config Config, opts ...ArgOptionFunc)

func (*GRun) Get added in v1.1.17

func (g *GRun) Get(id int) (*Item, bool)

func (*GRun) Wait added in v1.1.17

func (g *GRun) Wait()

type Item added in v1.1.17

type Item struct {
	Data interface{}
	// contains filtered or unexported fields
}

func NewItem added in v1.1.17

func NewItem(id int, args []string, data interface{}) *Item

func (*Item) GetId added in v1.1.17

func (it *Item) GetId() int

type ProcessCallback

type ProcessCallback func(cmd *Cmd, status Status, time int64)

type Status added in v1.1.0

type Status int

Jump to

Keyboard shortcuts

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