pidfile

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package pidfile 管理进程 PID 文件的读写,用于进程存活检测与单实例守护。

PID 文件默认保存在配置目录下,文件名为 ".{project}.pid"。 通过 pidfilebuilder 在服务启动后写入、停止后删除。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() (r result.Result[int])

Get 读取 PID 文件并返回进程 ID,文件不存在或内容非法时返回错误。

func GetPath

func GetPath() string

GetPath 返回 PID 文件的绝对路径。

func Remove added in v2.2.0

func Remove() (r result.Error)

Remove 删除 PID 文件,通常在进程优雅退出时调用。文件不存在时不视为错误。

func Save

func Save() (r result.Error)

Save 将当前进程 ID 写入 PID 文件。

Types

This section is empty.

Directories

Path Synopsis
Package pidfilebuilder 提供 lifecycle 钩子,在服务启动后写入 PID 文件、停止后删除。
Package pidfilebuilder 提供 lifecycle 钩子,在服务启动后写入 PID 文件、停止后删除。

Jump to

Keyboard shortcuts

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