From 7d7bca0375efd1d0e5b13195de1c3a5a3cf6dc1f Mon Sep 17 00:00:00 2001 From: Overbool Date: Fri, 21 Sep 2018 06:34:38 +0800 Subject: [PATCH] feat(daemon): print version License: MIT Signed-off-by: Overbool --- cmd/ipfs/daemon.go | 12 ++++++++++++ test/sharness/t0060-daemon.sh | 1 + 2 files changed, 13 insertions(+) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index 4f80579d1fb..a98d537f3a8 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -8,9 +8,11 @@ import ( "net/http" _ "net/http/pprof" "os" + "runtime" "sort" "sync" + version "github.com/ipfs/go-ipfs" utilmain "github.com/ipfs/go-ipfs/cmd/ipfs/util" oldcmds "github.com/ipfs/go-ipfs/commands" "github.com/ipfs/go-ipfs/core" @@ -194,6 +196,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment // let the user know we're going. fmt.Printf("Initializing daemon...\n") + // print the ipfs version + printVersion() + managefd, _ := req.Options[adjustFDLimitKwd].(bool) if managefd { if err := utilmain.ManageFdLimit(); err != nil { @@ -644,3 +649,10 @@ func YesNoPrompt(prompt string) bool { return false } + +func printVersion() { + fmt.Printf("go-ipfs version: %s-%s\n", version.CurrentVersionNumber, version.CurrentCommit) + fmt.Printf("Repo version: %d\n", fsrepo.RepoVersion) + fmt.Printf("System version: %s\n", runtime.GOARCH+"/"+runtime.GOOS) + fmt.Printf("Golang version: %s\n", runtime.Version()) +} diff --git a/test/sharness/t0060-daemon.sh b/test/sharness/t0060-daemon.sh index 2ec1fc38e61..01fba5936bf 100755 --- a/test/sharness/t0060-daemon.sh +++ b/test/sharness/t0060-daemon.sh @@ -42,6 +42,7 @@ test_expect_success "ipfs gateway works with the correct allowed origin port" ' test_expect_success "ipfs daemon output looks good" ' STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" && echo "Initializing daemon..." >expected_daemon && + ipfs version --all >> expected_daemon && sed "s/^/Swarm listening on /" listen_addrs >>expected_daemon && sed "s/^/Swarm announcing /" local_addrs >>expected_daemon && echo "API server listening on '$API_MADDR'" >>expected_daemon &&