sys

package
v0.0.0-...-20d904f Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 28 Imported by: 8

Documentation

Index

Constants

View Source
const SIGCHLD = syscall.Signal(17)

Variables

View Source
var ApplicationFullName string
View Source
var ApplicationName string
View Source
var ApplicationPath string
View Source
var ErrAlreadyDaemon error = errors.New("ErrAlreadyDaemon")
View Source
var ErrAlreadyWatchDog error = errors.New("ErrAlreadyWatchDog")
View Source
var ErrAlreadyWatchDog2 error = errors.New("ErrAlreadyWatchDog2")
View Source
var ErrNotSupportDaemon error = errors.New("ErrNotSupportDaemon")
View Source
var IsCgoEnabled bool
View Source
var MutexMap = xmap.NewMap[int64, *MutexEx]() //map[int64]*MutexEx

Functions

func AllocConsole

func AllocConsole(args ...string)

func BytesToPointer

func BytesToPointer(b []byte) unsafe.Pointer

func CPtrToBytes

func CPtrToBytes(ptr unsafe.Pointer, l int) []byte

func CPtrToString

func CPtrToString(ptr unsafe.Pointer, maxLen ...int) string

func CString

func CString(name string) *byte

func Callback

func Callback(arg1 *C.void, arg2 *C.void, arg3 *C.void, arg4 *C.void, arg5 *C.void, arg6 *C.void, arg7 *C.void, arg8 *C.void) *C.void

func CopyDir

func CopyDir(srcPath string, dstPath string) error

CopyDir 复制一个文件目录

func CopyFile

func CopyFile(dest, src string) error

func CopyFile2

func CopyFile2(dstName, srcName string) error

func DefaultDaemon

func DefaultDaemon() bool

func DefaultDog

func DefaultDog(logFile string) bool

func ErrToFile

func ErrToFile(filename string, mutiFile ...bool) bool

func FileExist

func FileExist(filename string) bool

FileExist 检查文件或目录是否存在 如果由 filename 指定的文件或目录存在则返回 true,否则返回 false

func FileExist2

func FileExist2(filename string) (bool, bool)

func FormatDir

func FormatDir(dir string) string

func FormatDirRoot

func FormatDirRoot(rootDir, dir string) string

func FreeConsole

func FreeConsole()

func GetCallFunctionName

func GetCallFunctionName(depth int) string

func GetCallInfo

func GetCallInfo(depth int) string

func GetFileName

func GetFileName(filename string) string

func GetFilePath

func GetFilePath(filename string) string

GetFilePath 获取文件的路径

func GetFuncInfo

func GetFuncInfo(v interface{}) (name string, file string, line int)

func GetFuncName

func GetFuncName(f interface{}) string

func Go

func Go(f interface{}, loop bool, arg ...interface{})

func GoBytes

func GoBytes(c uintptr, l int) []byte

func GoExit

func GoExit()

func GoID

func GoID() int

func GoString

func GoString(c unsafe.Pointer) string

func HideConsole

func HideConsole() uint64

func IsFileValid

func IsFileValid(f *os.File) bool

func IsNil

func IsNil(i interface{}) bool

func IsSameType

func IsSameType(t1, t2 reflect.Type) bool

func KillOneThread

func KillOneThread()

func ListenSignal

func ListenSignal(callback func(s os.Signal), signals []os.Signal)

func Mkdir

func Mkdir(path string) string

func MoveFile

func MoveFile(dest, src string) error

func NewCallback

func NewCallback(fn interface{}) uintptr

func NewSysProcAttr

func NewSysProcAttr(arg map[string]interface{}) *syscall.SysProcAttr

func OnPanic

func OnPanic(logFile bool)

func RandShort

func RandShort() string

func RandomUint32

func RandomUint32() uint32

func RecoverFunc

func RecoverFunc(file string, line int, errSave ...bool)

func ReopenStdout

func ReopenStdout()

func SetConsoleTitle

func SetConsoleTitle(text string)

func SetProcessName

func SetProcessName(name string) error

The new name can be at most 16 bytes.

func SetPts

func SetPts(pts_dev string) bool

func ShowConsole

func ShowConsole() uint64

func ShowMessage

func ShowMessage(title, text string, parent ...uintptr)

func StringToPointer

func StringToPointer(str string) unsafe.Pointer

func ULimit

func ULimit(max, cur int) error

func ULimitGet

func ULimitGet() (int, int, error)

Types

type Channel

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

func NewChannel

func NewChannel(name string, capacity int) *Channel

func (*Channel) Close

func (me *Channel) Close()

func (*Channel) Read

func (me *Channel) Read(timeoutMs int) (interface{}, error)

func (*Channel) SetWaitClose

func (me *Channel) SetWaitClose(second int)

func (*Channel) Write

func (me *Channel) Write(data interface{}) error

type DogCallback

type DogCallback func(restart *bool)

type GoRoutine

type GoRoutine struct {
	GoId      int64
	CallInfo  string
	CallTime  int64
	IsExit    bool
	CallCount cast.Int64
}

func DumpGo

func DumpGo() []*GoRoutine

type GoRoutineManager

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

func (*GoRoutineManager) Add

func (r *GoRoutineManager) Add(callInfo string) *GoRoutine

func (*GoRoutineManager) Count

func (r *GoRoutineManager) Count() int

func (*GoRoutineManager) Del

func (r *GoRoutineManager) Del(id int64)

func (*GoRoutineManager) DumpGo

func (r *GoRoutineManager) DumpGo() []*GoRoutine

func (*GoRoutineManager) Exit

func (r *GoRoutineManager) Exit()

func (*GoRoutineManager) Go

func (r *GoRoutineManager) Go(f interface{}, loop bool, arg ...interface{})

type GoRoutineSlice

type GoRoutineSlice []*GoRoutine

func (GoRoutineSlice) Len

func (g GoRoutineSlice) Len() int

func (GoRoutineSlice) Less

func (g GoRoutineSlice) Less(i, j int) bool

func (GoRoutineSlice) Swap

func (g GoRoutineSlice) Swap(i, j int)

type MutexEx

type MutexEx struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMutex

func NewMutex(name string) *MutexEx

func (*MutexEx) Close

func (me *MutexEx) Close()

func (*MutexEx) GetCallInfo

func (me *MutexEx) GetCallInfo() (string, int)

func (*MutexEx) GetInfo

func (me *MutexEx) GetInfo() string

func (*MutexEx) GetStatus

func (me *MutexEx) GetStatus() int8

func (*MutexEx) IsLock

func (me *MutexEx) IsLock() bool

func (*MutexEx) Lock

func (me *MutexEx) Lock()

func (*MutexEx) LockInfo

func (me *MutexEx) LockInfo(str string)

func (*MutexEx) RecordFile

func (me *MutexEx) RecordFile(v bool, deepth int)

func (*MutexEx) Unlock

func (me *MutexEx) Unlock()

func (*MutexEx) UnlockInfo

func (me *MutexEx) UnlockInfo(str string)

type ProcCallback

type ProcCallback func(args []interface{}, procInfo *ProcInfo)

type ProcInfo

type ProcInfo struct {
	Wg *sync.WaitGroup //用于多个go 同步

	SyncCh chan int //用于多个go 同步
	// contains filtered or unexported fields
}

func (*ProcInfo) Exit

func (me *ProcInfo) Exit(ret int)

func (*ProcInfo) GetCreateTime

func (me *ProcInfo) GetCreateTime() int64

func (*ProcInfo) GetHandup

func (me *ProcInfo) GetHandup() bool

func (*ProcInfo) GetName

func (me *ProcInfo) GetName() string

func (*ProcInfo) GetProcId

func (me *ProcInfo) GetProcId() int64

func (*ProcInfo) GetTick

func (me *ProcInfo) GetTick() int64

func (*ProcInfo) GetTickInterval

func (me *ProcInfo) GetTickInterval() int64

func (*ProcInfo) IsExit

func (me *ProcInfo) IsExit() bool

func (*ProcInfo) Notify

func (me *ProcInfo) Notify(v int)

func (*ProcInfo) SetFun

func (me *ProcInfo) SetFun(name string, fun ProcCallback)

func (*ProcInfo) SetSleepMs

func (me *ProcInfo) SetSleepMs(ms int)

type ProcMgr

type ProcMgr struct {
	Id int64
	// contains filtered or unexported fields
}

///////////////////////////////ProcMgr///////////////////////////////////////

var Process *ProcMgr

func NewProcMgr

func NewProcMgr() *ProcMgr

func (*ProcMgr) CheckProc

func (me *ProcMgr) CheckProc()

func (*ProcMgr) CreateProc

func (me *ProcMgr) CreateProc(name string, fun ProcCallback, args []interface{}) (*ProcInfo, bool)

callback:

func Callback(args []interface{}, procInfo *goapi.ProcInfo){
	if me.bExit == false {
	}else{
		procInfo.Exit(1)
	}
}

func (*ProcMgr) CreateProc2

func (me *ProcMgr) CreateProc2(name string, fun ProcCallback, args []interface{}) (*ProcInfo, bool)

不立即执行

func (*ProcMgr) EnableCheck

func (me *ProcMgr) EnableCheck(v bool)

func (*ProcMgr) ExitAllProcess

func (me *ProcMgr) ExitAllProcess()

func (*ProcMgr) GetFirstProcName

func (me *ProcMgr) GetFirstProcName() string

func (*ProcMgr) GetProcCount

func (me *ProcMgr) GetProcCount() int

func (*ProcMgr) GetProcMap

func (me *ProcMgr) GetProcMap() map[int64]*ProcInfo

func (*ProcMgr) Lock

func (me *ProcMgr) Lock()

func (*ProcMgr) Proc

func (me *ProcMgr) Proc(args []interface{}, procInfo *ProcInfo)

func (*ProcMgr) Start

func (me *ProcMgr) Start(procInfo *ProcInfo)

func (*ProcMgr) Unlock

func (me *ProcMgr) Unlock()

func (*ProcMgr) Wait

func (me *ProcMgr) Wait()

type ProcessGroup

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

func ProcessGroupNew

func ProcessGroupNew() *ProcessGroup

func (*ProcessGroup) Add

func (me *ProcessGroup) Add(proc *ProcInfo)

func (*ProcessGroup) Stop

func (me *ProcessGroup) Stop()

type RandEx

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

func NewRand

func NewRand() *RandEx

func (*RandEx) Int

func (me *RandEx) Int(max int) int

func (*RandEx) Int64

func (me *RandEx) Int64(max int64) int64

func (*RandEx) Intn

func (me *RandEx) Intn(min, max int) int

type WatchDog

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

func NewWatchDog

func NewWatchDog() *WatchDog

func (*WatchDog) AddEnv

func (me *WatchDog) AddEnv(value string)

func (*WatchDog) AllocDebugConsole

func (me *WatchDog) AllocDebugConsole() *os.File

func (*WatchDog) IsFileValid

func (me *WatchDog) IsFileValid(f *os.File) bool

func (*WatchDog) RunDaemon

func (me *WatchDog) RunDaemon(stdout *os.File) error

func (*WatchDog) RunWatchDog

func (me *WatchDog) RunWatchDog(errDaemonFile, logPrefix string, stdout *os.File, stdin *os.File, callback ...DogCallback) error

die loop

func (*WatchDog) SetAppFilename

func (me *WatchDog) SetAppFilename(filename string)

func (*WatchDog) SetStderr

func (me *WatchDog) SetStderr(stderr *os.File)

func (*WatchDog) SetStdin

func (me *WatchDog) SetStdin(stdin *os.File)

func (*WatchDog) SetStdout

func (me *WatchDog) SetStdout(stdout *os.File)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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