Skip to content

Commit 7d7bca0

Browse files
committed
feat(daemon): print version
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
1 parent 987fef1 commit 7d7bca0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/ipfs/daemon.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import (
88
"net/http"
99
_ "net/http/pprof"
1010
"os"
11+
"runtime"
1112
"sort"
1213
"sync"
1314

15+
version "github.com/ipfs/go-ipfs"
1416
utilmain "github.com/ipfs/go-ipfs/cmd/ipfs/util"
1517
oldcmds "github.com/ipfs/go-ipfs/commands"
1618
"github.com/ipfs/go-ipfs/core"
@@ -194,6 +196,9 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
194196
// let the user know we're going.
195197
fmt.Printf("Initializing daemon...\n")
196198

199+
// print the ipfs version
200+
printVersion()
201+
197202
managefd, _ := req.Options[adjustFDLimitKwd].(bool)
198203
if managefd {
199204
if err := utilmain.ManageFdLimit(); err != nil {
@@ -644,3 +649,10 @@ func YesNoPrompt(prompt string) bool {
644649

645650
return false
646651
}
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ test_expect_success "ipfs gateway works with the correct allowed origin port" '
4242
test_expect_success "ipfs daemon output looks good" '
4343
STARTFILE="ipfs cat /ipfs/$HASH_WELCOME_DOCS/readme" &&
4444
echo "Initializing daemon..." >expected_daemon &&
45+
ipfs version --all >> expected_daemon &&
4546
sed "s/^/Swarm listening on /" listen_addrs >>expected_daemon &&
4647
sed "s/^/Swarm announcing /" local_addrs >>expected_daemon &&
4748
echo "API server listening on '$API_MADDR'" >>expected_daemon &&

0 commit comments

Comments
 (0)