Commit aea52132 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

cmd/ipfs: Initialize IpfsNode when running locally or starting daemon

parent 7b2f4488
......@@ -9,6 +9,7 @@ import (
cmds "github.com/jbenet/go-ipfs/commands"
cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/daemon"
)
......@@ -20,10 +21,15 @@ var Daemon = &cmds.Command{
}
func daemonFunc(req cmds.Request, res cmds.Response) {
// TODO: spin up a core.IpfsNode
ctx := req.Context()
node, err := core.NewIpfsNode(ctx.Config, true)
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
ctx.Node = node
lk, err := daemon.Lock(ctx.ConfigRoot)
if err != nil {
res.SetError(fmt.Errorf("Couldn't obtain lock. Is another daemon already running?"), cmds.ErrNormal)
......
......@@ -10,6 +10,7 @@ import (
cmdsCli "github.com/jbenet/go-ipfs/commands/cli"
cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
"github.com/jbenet/go-ipfs/config"
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/core/commands"
"github.com/jbenet/go-ipfs/daemon"
u "github.com/jbenet/go-ipfs/util"
......@@ -110,7 +111,13 @@ func main() {
}
} else {
// TODO: spin up node
node, err := core.NewIpfsNode(conf, false)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
ctx.Node = node
res = root.Call(req)
}
}
......
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