Categorygithub.com/coccodrillo/singleprocess
repositorypackage
0.0.0-20170411183510-71d4f9a99eeb
Repository: https://github.com/coccodrillo/singleprocess.git
Documentation: pkg.go.dev

# README

Single process checker

singleprocess is a library for Go that implements checking if a process with the same name already exists. It is useful for checking cron jobs you don't want to overlap.

It uses Mitchel Hashimoto's go-ps. I have only tested it on "darwin" and "linux" systems.

Installation

Install using standard go get:

$ go get github.com/Coccodrillo/singleprocess

Usage:

import (
	...
	"github.com/Coccodrillo/singleprocess"
	...
)

func main() {
	if singleprocess.IsAnotherInstanceRunning() {
		// Do something, for instance exit
		os.Exit(1)
	}
}

TODO

Adapt for other plaforms, namely Windows, FreeBSD...