Documentation ¶
Index ¶
- Constants
- Variables
- func AsyExec(cmd string) <-chan CmdResult
- func ChildRunning(fn func(), exits ...func())
- func Closed() <-chan bool
- func Closing()
- func CpuPercent() float64
- func CreateTmpShellFile(pattern, content string) (tmpFile string, err error)
- func GetClientIP() ([]net.IP, error)
- func GetPublicIP() (net.IP, error)
- func GetPublicIPWithUrl(url string) (net.IP, error)
- func GetResolveIP() (net.IP, error)
- func GetResolveIPV2() (net.IP, error)
- func GetResolveIPV3(tt IPType) (net.IP, error)
- func IPIsSelf(ip string) string
- func Info() string
- func IsLanIP(IP net.IP) bool
- func IsPublicIP(IP net.IP) bool
- func MainRunning(fn func(), exits ...func())
- func PortUsed(port int) bool
- func PortsUsed(ports []int) []bool
- func PublicIPValid() bool
- func Quit()
- func Recover(cleanups ...func())
- func Run()
- func SIToString(d *DiskPath, m *MemInfo, cpuPercent float64) string
- func SelfExternalIP(lan bool) string
- func StripArgs(args []string, arg string) []string
- type ArgOption
- type ArgOptionFunc
- type Child
- type Cmd
- type CmdResult
- type Config
- type CpuInfo
- type Daemon
- type DaemonConfig
- type DiskPath
- type Event
- type ExitSig
- type GroupRun
- type IPType
- type MemInfo
- type Monitor
- type ProcessCallback
- type RecoverFunc
- type Running
- type RunningCheck
- type Shell
- type Status
Constants ¶
View Source
const ( KStatusRunning = Status(1) KStatusClose = Status(2) KStatusExit = Status(3) )
View Source
const ( IptUnk = IPType(0) IptPub = IPType(1) IptPriA = IPType(2) IptPriB = IPType(3) IptPriC = IPType(4) )
View Source
const GB = 1024 * 1024 * 1024
View Source
const (
KLocalHost = "127.0.0.1"
)
View Source
const KMaxGroupCount = 3000
Variables ¶
View Source
var ( DefaultDaemonConfig = DaemonConfig{Config: Config{EnableEnv: true, EnableStd: false}} DefaultGroupRun *GroupRun = nil CmdNilErr = errors.New("cmd obj is nil") MaxCountErr = errors.New("max count") MaxErr = errors.New("max error") )
View Source
var ( ResolveIp = net.IP{} PublicIp = net.IP{} )
Functions ¶
func ChildRunning ¶ added in v1.8.0
func ChildRunning(fn func(), exits ...func())
func CpuPercent ¶ added in v1.4.9
func CpuPercent() float64
func CreateTmpShellFile ¶ added in v1.1.11
CreateTmpShellFile 创建临时的 shell 脚本文件 content 创建的脚本内容
func GetClientIP ¶ added in v1.4.13
func GetPublicIP ¶ added in v0.5.39
func GetResolveIP ¶ added in v0.5.39
func GetResolveIPV2 ¶ added in v0.5.39
func IsPublicIP ¶
func MainRunning ¶ added in v1.8.0
func MainRunning(fn func(), exits ...func())
func PublicIPValid ¶ added in v0.7.0
func PublicIPValid() bool
func SIToString ¶ added in v1.4.9
func SelfExternalIP ¶ added in v1.1.3
SelfExternalIP 自己外部IP,可能是局域网IP,公网IP lan 局域网优先
Types ¶
type ArgOptionFunc ¶ added in v1.6.21
type ArgOptionFunc func(arg *ArgOption)
type Child ¶ added in v1.6.21
type Child struct { Data interface{} // contains filtered or unexported fields }
type Cmd ¶ added in v1.6.21
type CmdResult ¶ added in v1.1.19
type CmdResult struct { Command string Err error StartTime time.Time EndTime time.Time // contains filtered or unexported fields }
type CpuInfo ¶ added in v1.0.16
type Daemon ¶ added in v1.6.21
type Daemon struct { }
func (*Daemon) Background ¶ added in v1.6.21
func (*Daemon) Background(id int, args []string, conf DaemonConfig, opts ...ArgOptionFunc) (*Cmd, error)
func (*Daemon) Group ¶ added in v1.6.21
func (*Daemon) Group(group int, args []string, cb ProcessCallback, config DaemonConfig, opts ...ArgOptionFunc)
Group 守护进程启动一个N[1,2000]子进程, 并循环监视
func (*Daemon) Run ¶ added in v1.6.21
func (d *Daemon) Run(groupId int, args []string, cb ProcessCallback, config DaemonConfig, opts ...ArgOptionFunc) int
Run 守护进程启动一个子进程, 并循环监视
type DaemonConfig ¶ added in v1.6.21
type DiskPath ¶ added in v1.0.16
type DiskPath struct { Path string `json:"path,omitempty"` Total uint64 `json:"total"` Free uint64 `json:"free"` Used uint64 `json:"used"` UsedPercent float64 `json:"usedPercent"` }
func DiskWithPath ¶ added in v1.8.36
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event represents a one-time event that may occur in the future.
func (*Event) Done ¶
func (e *Event) Done() <-chan struct{}
Done returns a channel that will be closed when Fire is called.
type GroupRun ¶ added in v1.6.21
type GroupRun struct {
// contains filtered or unexported fields
}
func (*GroupRun) Exec ¶ added in v1.6.21
func (g *GroupRun) Exec(cb ProcessCallback, config DaemonConfig, opts ...ArgOptionFunc)
type MemInfo ¶ added in v1.0.0
type MemInfo struct { // Total amount of RAM on this system Total uint64 `json:"total"` // RAM available for programs to allocate // // This value is computed from the kernel specific values. Available uint64 `json:"available"` // RAM used by programs // // This value is computed from the kernel specific values. Used uint64 `json:"used"` // Percentage of RAM used by programs // // This value is computed from the kernel specific values. UsedPercent float64 `json:"usedPercent"` }
type Monitor ¶ added in v1.4.9
type ProcessCallback ¶ added in v1.6.21
type RecoverFunc ¶ added in v1.8.0
type RecoverFunc func(r any)
var DefRecoverFunc RecoverFunc = func(r any) {
}
type Running ¶ added in v1.6.6
type Running struct {
// contains filtered or unexported fields
}
type RunningCheck ¶ added in v1.8.0
type RunningCheck struct {
// contains filtered or unexported fields
}
func (*RunningCheck) IsRunning ¶ added in v1.8.0
func (rc *RunningCheck) IsRunning() bool
func (*RunningCheck) TryGoRunning ¶ added in v1.8.0
func (rc *RunningCheck) TryGoRunning(fn func(), exits ...func())
Source Files ¶
Click to show internal directories.
Click to hide internal directories.