pid

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemovePidFile

func RemovePidFile(homePath string)

RemovePidFile deletes the PID file (e.g. on graceful shutdown).

func RemovePidFileIfPID added in v0.2.6

func RemovePidFileIfPID(homePath string, expectedPID int) bool

RemovePidFileIfPID deletes the PID file only when the recorded PID matches expectedPID. It returns true when the file is removed successfully.

Types

type PidFileData

type PidFileData struct {
	PID     int    `json:"pid"`
	Token   string `json:"token"`
	Version string `json:"version"`
	Port    int    `json:"port"`
	Host    string `json:"host"`
}

PidFileData is the JSON structure stored in the PID file.

func ReadPidFileWithCheck

func ReadPidFileWithCheck(homePath string) *PidFileData

ReadPidFileWithCheck reads the PID file and additionally checks if the recorded process is still alive. Returns nil if the file is missing, unreadable, or the process has exited.

func WritePidFile

func WritePidFile(homePath, host string, port int) (*PidFileData, error)

WritePidFile creates (or overwrites) the PID file atomically. It returns an error if another gateway instance appears to be running (a valid PID file exists with a live process).

Jump to

Keyboard shortcuts

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