feat(daemon): print version
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
Overbool committed
Sep 21, 2018 at 06:34 UTC
7d7bca0375efd1d0e5b13195de1c3a5a3cf6dc1f
2 files changed
+13
cmd/ipfs/daemon.go
+12
@@ -8,9 +8,11 @@ import (
8
"net/http"
9
_ "net/http/pprof"
10
"os"
11
+ "runtime"
12
"sort"
13
"sync"
14
15
+ version "github.com/ipfs/go-ipfs"
16
utilmain "github.com/ipfs/go-ipfs/cmd/ipfs/util"
17
oldcmds "github.com/ipfs/go-ipfs/commands"
18
"github.com/ipfs/go-ipfs/core"
@@ -194,6 +196,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
196
// let the user know we're going.
197
fmt.Printf("Initializing daemon...\n")
198
199
+ // print the ipfs version
200
+ printVersion()
201
+
202
managefd, _ := req.Options[adjustFDLimitKwd].(bool)
203
if managefd {
204
if err := utilmain.ManageFdLimit(); err != nil {
@@ -644,3 +649,10 @@ func YesNoPrompt(prompt string) bool {
649
650
return false
651
}
652
+
653
+func printVersion() {
654
+ fmt.Printf("go-ipfs version: %s-%s\n", version.CurrentVersionNumber, version.CurrentCommit)
655
+ fmt.Printf("Repo version: %d\n", fsrepo.RepoVersion)
656
+ fmt.Printf("System version: %s\n", runtime.GOARCH+"/"+runtime.GOOS)
657
+ fmt.Printf("Golang version: %s\n", runtime.Version())
658
+}
test/sharness/t0060-daemon.sh
+1
@@ -42,6 +42,7 @@ test_expect_success "ipfs gateway works with the correct allowed origin port" '
42
test_expect_success "ipfs daemon output looks good" '
43
STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
44
echo "Initializing daemon..." >expected_daemon &&
45
+ ipfs version --all >> expected_daemon &&
46
sed "s/^/Swarm listening on /" listen_addrs >>expected_daemon &&
47
sed "s/^/Swarm announcing /" local_addrs >>expected_daemon &&
48
echo "API server listening on '$API_MADDR'" >>expected_daemon &&