upgrade shutdown command to the new commands lib
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Jul 31, 2018 at 12:45 UTC
8bcf6f48d9ebdb49839edcd02692f968e78e14b2
2 files changed
+6
-9
core/commands/root.go
+1
-1
@@ -138,7 +138,7 @@ var rootSubcommands = map[string]*cmds.Command{
138
"update": lgc.NewCommand(ExternalBinary()),
139
"urlstore": urlStoreCmd,
140
"version": lgc.NewCommand(VersionCmd),
141
- "shutdown": lgc.NewCommand(daemonShutdownCmd),
141
+ "shutdown": daemonShutdownCmd,
142
}
143
144
// RootRO is the readonly version of Root
core/commands/shutdown.go
+5
-8
@@ -3,31 +3,28 @@ package commands
3
import (
4
"fmt"
5
6
+ cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds"
7
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
7
-
8
- cmds "github.com/ipfs/go-ipfs/commands"
8
)
9
10
var daemonShutdownCmd = &cmds.Command{
11
Helptext: cmdkit.HelpText{
12
Tagline: "Shut down the ipfs daemon",
13
},
15
- Run: func(req cmds.Request, res cmds.Response) {
16
- nd, err := req.InvocContext().GetNode()
14
+ Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) {
15
+ nd, err := GetNode(env)
16
if err != nil {
18
- res.SetError(err, cmdkit.ErrNormal)
17
+ re.SetError(err, cmdkit.ErrNormal)
18
return
19
}
20
21
if nd.LocalMode() {
23
- res.SetError(fmt.Errorf("daemon not running"), cmdkit.ErrClient)
22
+ re.SetError(fmt.Errorf("daemon not running"), cmdkit.ErrClient)
23
return
24
}
25
26
if err := nd.Process().Close(); err != nil {
27
log.Error("error while shutting down ipfs daemon:", err)
28
}
30
-
31
- res.SetOutput(nil)
29
},
30
}