-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
License: MIT Signed-off-by: Jeromy <[email protected]>
- Loading branch information
1 parent
e5529cd
commit 331bc1b
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
cmds "github.com/ipfs/go-ipfs/commands" | ||
) | ||
|
||
var DaemonShutdownCmd = &cmds.Command{ | ||
Helptext: cmds.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, cmds.ErrNormal) | ||
return | ||
} | ||
|
||
if nd.LocalMode() { | ||
res.SetError(fmt.Errorf("daemon not running"), cmds.ErrClient) | ||
return | ||
} | ||
|
||
if err := nd.Process().Close(); err != nil { | ||
log.Error("error while shutting down ipfs daemon:", err) | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2017 Jeromy Johnson | ||
# MIT Licensed; see the LICENSE file in this repository. | ||
# | ||
|
||
test_description="Test shutdown command" | ||
|
||
. lib/test-lib.sh | ||
|
||
test_init_ipfs | ||
|
||
test_launch_ipfs_daemon | ||
|
||
test_expect_success "shutdown succeeds" ' | ||
ipfs shutdown | ||
' | ||
|
||
test_expect_success "daemon no longer running" ' | ||
test_expect_code 1 kill -0 $IPFS_PID | ||
' | ||
|
||
test_launch_ipfs_daemon --offline | ||
|
||
test_expect_success "shutdown succeeds" ' | ||
ipfs shutdown | ||
' | ||
|
||
test_expect_success "daemon no longer running" ' | ||
test_expect_code 1 kill -0 $IPFS_PID | ||
' | ||
test_done |