Commit e311ccbf authored by Jeromy's avatar Jeromy Committed by Juan Batiz-Benet

respect the lock file, also cpu profile

parent 9c221719
......@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"runtime/pprof"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
......@@ -67,7 +68,15 @@ func ipfsCmd(c *commander.Command, args []string) error {
func main() {
u.Debug = true
err := CmdIpfs.Dispatch(os.Args[1:])
ofi, err := os.Create("cpu.prof")
if err != nil {
fmt.Println(err)
return
}
pprof.StartCPUProfile(ofi)
defer ofi.Close()
defer pprof.StopCPUProfile()
err = CmdIpfs.Dispatch(os.Args[1:])
if err != nil {
if len(err.Error()) > 0 {
fmt.Fprintf(os.Stderr, "ipfs %s: %v\n", os.Args[1], err)
......
......@@ -8,7 +8,9 @@ import (
"net"
"os"
lock "github.com/camlistore/lock"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
u "github.com/jbenet/go-ipfs/util"
)
......@@ -46,6 +48,21 @@ func getDaemonAddr(confdir string) (string, error) {
// address of the daemon is retrieved from the configuration directory, where
// live daemons write their addresses to special files.
func SendCommand(command *Command, confdir string) error {
//check if daemon is running
log.Info("Checking if daemon is running...")
var err error
confdir, err = u.TildeExpansion(confdir)
if err != nil {
return err
}
lk, err := lock.Lock(confdir + "/daemon.lock")
if err == nil {
return ErrDaemonNotRunning
lk.Close()
}
log.Info("Daemon is running! %s", err)
server, err := getDaemonAddr(confdir)
if err != nil {
return err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment