Commit 8bcf6f48 authored by Steven Allen's avatar Steven Allen

upgrade shutdown command to the new commands lib

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent 4bca53e0
...@@ -138,7 +138,7 @@ var rootSubcommands = map[string]*cmds.Command{ ...@@ -138,7 +138,7 @@ var rootSubcommands = map[string]*cmds.Command{
"update": lgc.NewCommand(ExternalBinary()), "update": lgc.NewCommand(ExternalBinary()),
"urlstore": urlStoreCmd, "urlstore": urlStoreCmd,
"version": lgc.NewCommand(VersionCmd), "version": lgc.NewCommand(VersionCmd),
"shutdown": lgc.NewCommand(daemonShutdownCmd), "shutdown": daemonShutdownCmd,
} }
// RootRO is the readonly version of Root // RootRO is the readonly version of Root
......
...@@ -3,31 +3,28 @@ package commands ...@@ -3,31 +3,28 @@ package commands
import ( import (
"fmt" "fmt"
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit" "gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
cmds "github.com/ipfs/go-ipfs/commands"
) )
var daemonShutdownCmd = &cmds.Command{ var daemonShutdownCmd = &cmds.Command{
Helptext: cmdkit.HelpText{ Helptext: cmdkit.HelpText{
Tagline: "Shut down the ipfs daemon", Tagline: "Shut down the ipfs daemon",
}, },
Run: func(req cmds.Request, res cmds.Response) { Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) {
nd, err := req.InvocContext().GetNode() nd, err := GetNode(env)
if err != nil { if err != nil {
res.SetError(err, cmdkit.ErrNormal) re.SetError(err, cmdkit.ErrNormal)
return return
} }
if nd.LocalMode() { if nd.LocalMode() {
res.SetError(fmt.Errorf("daemon not running"), cmdkit.ErrClient) re.SetError(fmt.Errorf("daemon not running"), cmdkit.ErrClient)
return return
} }
if err := nd.Process().Close(); err != nil { if err := nd.Process().Close(); err != nil {
log.Error("error while shutting down ipfs daemon:", err) log.Error("error while shutting down ipfs daemon:", err)
} }
res.SetOutput(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