Documentation
¶
Overview ¶
Package service 把 Gately 注册为系统服务,实现开机自启与异常退出后自动拉起: Linux 使用 systemd,macOS 使用 launchd,Windows 使用服务控制管理器(SCM)。 入口是命令 gately service install|uninstall|start|stop|restart|status。
Index ¶
Constants ¶
const ( // Name 是服务名:systemd 单元名、Windows 服务名 Name = "gately" // Label 是 macOS launchd 的标识 Label = "cn.gately.gately" )
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigDir ¶
DefaultConfigDir 返回服务模式下默认的配置目录,与 deploy/systemd 的约定一致。
func RunAsWindowsService ¶
RunAsWindowsService 在 Windows 以外的系统上不会被调用。
Types ¶
type Spec ¶
type Spec struct {
// Exe 是 Gately 可执行文件的绝对路径,服务直接引用它,在线升级替换该文件即可
Exe string
// ConfigDir 是配置目录的绝对路径
ConfigDir string
// Listen 非空时作为 -listen 参数传给服务
Listen string
// User 表示 macOS 上注册为当前用户的登录项(LaunchAgent),默认注册为开机启动的系统服务(LaunchDaemon)
User bool
// NoStart 表示只注册,不立即启动
NoStart bool
}
Spec 描述要注册的服务。