Documentation ¶
Overview ¶
Package pid provides methods for working with PID files
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Dir = "/var/run"
Dir is a path to directory with PID files
Functions ¶
func Create ¶
Create creates file with process PID file
Example ¶
// You can set default directory for pid files Dir = "/home/user/my-pids" err := Create("servicename") if err != nil { fmt.Printf("Error: %v\n", err) } fmt.Println("PID file created!")
Output:
func Get ¶
Get returns PID from PID file
Example ¶
pid := Get("servicename") if pid == -1 { fmt.Println("Can't read PID from PID file") } fmt.Printf("PID is %d\n", pid)
Output:
func IsProcessWorks ¶
IsProcessWorks returns true if process with given PID is works
Example ¶
pid := 1234 if IsProcessWorks(pid) { fmt.Printf("Process with PID %d is works\n", pid) } else { fmt.Printf("Process with PID %d isn't working\n", pid) }
Output:
func IsWorks ¶
IsWorks returns true if process with PID from PID file is works
Example ¶
if IsWorks("servicename") { fmt.Println("Process is works") } else { fmt.Println("Process isn't working") }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.