Documentation
¶
Index ¶
- Constants
- func Background(appPath string, args []string, logFile string) (*exec.Cmd, error)
- func GetLogFile(serviceName string) string
- func GetPidFilePath(serviceName string) string
- func Kill(pid int) error
- func NewSysProcAttr() *syscall.SysProcAttr
- func ReadPid(serviceInfo configuration.ServiceInfo) int
- func ReadPidFile(name string) (pid int, err error)
- func StartEngine(ctx context.Context, serviceInfo configuration.ServiceInfo, start ServiceStart)
- func WaitServiceStop(ctx context.Context, closeCallback func())
- type PidFileLocker
- type ServiceCloseCallback
- type ServiceStart
Constants ¶
View Source
const ENVDaemonIndex = "__DAEMON_IDX"
View Source
const Env_DaemonMode = "__DaemonMode"
Variables ¶
This section is empty.
Functions ¶
func Background ¶
把本身程序转化为后台运行(启动一个子进程, 然后自己退出) logFile 若不为空,子程序的标准输出和错误输出将记入此文件 isExit 启动子加进程后是否直接退出主程序, 若为false, 主程序返回*os.Process, 子程序返回 nil. 需自行判断处理
func GetLogFile ¶
func GetPidFilePath ¶
func NewSysProcAttr ¶
func NewSysProcAttr() *syscall.SysProcAttr
func ReadPid ¶
func ReadPid(serviceInfo configuration.ServiceInfo) int
func ReadPidFile ¶
func StartEngine ¶
func StartEngine(ctx context.Context, serviceInfo configuration.ServiceInfo, start ServiceStart)
func WaitServiceStop ¶
Types ¶
type PidFileLocker ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.