1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-18 03:10:41 +08:00
Files
kubo/core/commands/shutdown.go
Jeromy 267c19ab9d some fixes for latest from go-ipfs-cmds
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2018-01-21 11:11:47 -08:00

34 lines
672 B
Go

package commands
import (
"fmt"
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/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)
},
}