daemon

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAgent    = daemon.UserAgent
	GlobalAgent  = daemon.GlobalAgent
	GlobalDaemon = daemon.GlobalDaemon
	SystemDaemon = daemon.SystemDaemon
)

Variables

This section is empty.

Functions

func Run

func Run(serviceName string, serviceDescription string, kind daemon.Kind, dependencies []string, onStart func(), onShutdown func() error)

启动服务,一般在 main() 函数中执行 serviceName 服务名称 serviceDescription 服务介绍 kind 服务类型,darwin 不能使用 SystemDaemon,freebsd、linux、windows 只能使用 SystemDaemon dependencies 服务依赖项,一般为 nil onStart 启动服务函数,如果函数内有阻塞的代码(比如监听服务器),需要自己创建 goroutine onShutdown 关闭服务函数,用于接收到关闭信号后执行相应的清理,当函数结束时进程将退出

func SetLogFunc

func SetLogFunc(f func(format string, a ...interface{}))

设置日志记录函数

Types

type Kind added in v1.7.3

type Kind daemon.Kind

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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