kubo/core/commands/shutdown.go
Steven Allen 76e1da02a8 gx: massive update
Note: This commit is technically broken. However, I need to make a bunch of
cmds changes to make this work and I'd rather not bundle both changes into a
single commit.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2017-11-20 22:20:27 -08:00

34 lines
672 B
Go

package commands
import (
"fmt"
"gx/ipfs/QmUyfy4QSr3NXym4etEiRyxBLqqAeKHJuRdi8AACxg63fZ/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()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
}
if nd.LocalMode() {
res.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)
},
}