daemon.go 463 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
package daemon

import (
	"io"
	"path"

	lock "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/camlistore/lock"
)

// LockFile is the filename of the daemon lock, relative to config dir
const LockFile = "daemon.lock"

13 14
func Lock(confdir string) (io.Closer, error) {
	return lock.Lock(path.Join(confdir, LockFile))
15 16
}

17 18 19
func Locked(confdir string) bool {
	if lk, err := Lock(confdir); err != nil {
		return true
20

21 22 23
	} else {
		lk.Close()
		return false
24 25
	}
}