Skip to content

rfyiamcool/go-fcntl-pid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-fcntl-pid

use syscall.flock() to write pid file, avoid concurrently start to cause bug concurrently .

example:

package main

import (
	"fmt"
	"time"

	"github.com/rfyiamcool/go-fcntl-pid"
)

func pp() {
	for {
		time.Sleep(1 * time.Second)
		fmt.Println("trigger keepalive")
	}
}

func main() {
	filename := "mm.pid"
	pidfile.CheckExit(filename)
	pp()
}

Packages

No packages published

Languages