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{
"update": lgc.NewCommand(ExternalBinary()),
"urlstore": urlStoreCmd,
"version": lgc.NewCommand(VersionCmd),
"shutdown": lgc.NewCommand(daemonShutdownCmd),
"shutdown": daemonShutdownCmd,
}
// RootRO is the readonly version of Root
......
......@@ -3,31 +3,28 @@ package commands
import (
"fmt"
cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
cmds "github.com/ipfs/go-ipfs/commands"
)
var daemonShutdownCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Shut down the ipfs daemon",
},
Run: func(req cmds.Request, res cmds.Response) {
nd, err := req.InvocContext().GetNode()
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) {
nd, err := GetNode(env)
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
re.SetError(err, cmdkit.ErrNormal)
return
}
if nd.LocalMode() {
res.SetError(fmt.Errorf("daemon not running"), cmdkit.ErrClient)
re.SetError(fmt.Errorf("daemon not running"), cmdkit.ErrClient)
return
}
if err := nd.Process().Close(); err != nil {
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