engine

package
v0.0.0-...-9135e14 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const ENVDaemonIndex = "__DAEMON_IDX"
View Source
const Env_DaemonMode = "__DaemonMode"

Variables

This section is empty.

Functions

func Background

func Background(appPath string, args []string, logFile string) (*exec.Cmd, error)

把本身程序转化为后台运行(启动一个子进程, 然后自己退出) logFile 若不为空,子程序的标准输出和错误输出将记入此文件 isExit 启动子加进程后是否直接退出主程序, 若为false, 主程序返回*os.Process, 子程序返回 nil. 需自行判断处理

func GetLogFile

func GetLogFile(serviceName string) string

func GetPidFilePath

func GetPidFilePath(serviceName string) string

func Kill

func Kill(pid int) error

func NewSysProcAttr

func NewSysProcAttr() *syscall.SysProcAttr

func ReadPid

func ReadPid(serviceInfo configuration.ServiceInfo) int

func ReadPidFile

func ReadPidFile(name string) (pid int, err error)

func StartEngine

func StartEngine(ctx context.Context, serviceInfo configuration.ServiceInfo, start ServiceStart)

func WaitServiceStop

func WaitServiceStop(ctx context.Context, closeCallback func())

Types

type PidFileLocker

type PidFileLocker struct {
	*os.File
}

func CreatePidFileLocker

func CreatePidFileLocker(name string, perm os.FileMode) (lock *PidFileLocker, err error)

func NewPidFileLocker

func NewPidFileLocker(file *os.File) *PidFileLocker

func OpenPidFileLocker

func OpenPidFileLocker(name string, perm os.FileMode) (lock *PidFileLocker, err error)

func (*PidFileLocker) Lock

func (file *PidFileLocker) Lock() error

func (*PidFileLocker) ReadPid

func (file *PidFileLocker) ReadPid() (pid int, err error)

func (*PidFileLocker) Remove

func (file *PidFileLocker) Remove() error

func (*PidFileLocker) Unlock

func (file *PidFileLocker) Unlock() error

func (*PidFileLocker) WritePid

func (file *PidFileLocker) WritePid() (err error)

type ServiceCloseCallback

type ServiceCloseCallback func()

type ServiceStart

type ServiceStart func(ctx context.Context, cmd *cobra.Command, args []string) (ServiceCloseCallback, error)

Jump to

Keyboard shortcuts

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