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

cmd/ipfs2: daemon command: Handle lock before initializing node

parent decda218
......@@ -23,19 +23,19 @@ var daemonCmd = &cmds.Command{
func daemonFunc(res cmds.Response, req cmds.Request) {
ctx := req.Context()
node, err := core.NewIpfsNode(ctx.Config, true)
lk, err := daemon.Lock(ctx.ConfigRoot)
if err != nil {
res.SetError(err, cmds.ErrNormal)
res.SetError(fmt.Errorf("Couldn't obtain lock. Is another daemon already running?"), cmds.ErrNormal)
return
}
ctx.Node = node
defer lk.Close()
lk, err := daemon.Lock(ctx.ConfigRoot)
node, err := core.NewIpfsNode(ctx.Config, true)
if err != nil {
res.SetError(fmt.Errorf("Couldn't obtain lock. Is another daemon already running?"), cmds.ErrNormal)
res.SetError(err, cmds.ErrNormal)
return
}
defer lk.Close()
ctx.Node = node
addr, err := ma.NewMultiaddr(ctx.Config.Addresses.API)
if err != nil {
......
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