github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/daemon2/daemon.go (about)

     1  package daemon
     2  
     3  import (
     4  	"io"
     5  	"path"
     6  
     7  	lock "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/camlistore/lock"
     8  )
     9  
    10  // LockFile is the filename of the daemon lock, relative to config dir
    11  const LockFile = "daemon.lock"
    12  
    13  func Lock(confdir string) (io.Closer, error) {
    14  	return lock.Lock(path.Join(confdir, LockFile))
    15  }
    16  
    17  func Locked(confdir string) bool {
    18  	if lk, err := Lock(confdir); err != nil {
    19  		return true
    20  
    21  	} else {
    22  		lk.Close()
    23  		return false
    24  	}
    25  }