From e2783d6ef1997a7af1be98b3145398b823759e54 Mon Sep 17 00:00:00 2001
From: Manish R Jain <manish@dgraph.io>
Date: Wed, 18 Jul 2018 11:46:38 -0700
Subject: [PATCH] Print version when running Dgraph.

---
 dgraph/cmd/bulk/run.go    | 3 ++-
 dgraph/cmd/root.go        | 2 +-
 dgraph/cmd/server/run.go  | 1 +
 dgraph/cmd/version/run.go | 5 ++++-
 dgraph/cmd/zero/run.go    | 1 +
 x/init.go                 | 4 +---
 6 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/dgraph/cmd/bulk/run.go b/dgraph/cmd/bulk/run.go
index 565652c2..de9eafda 100644
--- a/dgraph/cmd/bulk/run.go
+++ b/dgraph/cmd/bulk/run.go
@@ -98,7 +98,8 @@ func run() {
 	}
 
 	if opt.Version {
-		x.PrintVersionOnly()
+		x.PrintVersion()
+		os.Exit(0)
 	}
 	if opt.RDFDir == "" || opt.SchemaFile == "" {
 		flag.Usage()
diff --git a/dgraph/cmd/root.go b/dgraph/cmd/root.go
index 51c1045c..1b6a4b91 100644
--- a/dgraph/cmd/root.go
+++ b/dgraph/cmd/root.go
@@ -27,7 +27,7 @@ var RootCmd = &cobra.Command{
 	Use:   "dgraph",
 	Short: "Dgraph: Distributed Graph Database",
 	Long: `
-Dgraph is an open source, horizontally scalable and distributed graph database,
+Dgraph is a horizontally scalable and distributed graph database,
 providing ACID transactions, consistent replication and linearizable reads.
 It's built from ground up to perform for a rich set of queries. Being a native
 graph database, it tightly controls how the data is arranged on disk to optimize
diff --git a/dgraph/cmd/server/run.go b/dgraph/cmd/server/run.go
index c31f7972..2d2f07b8 100644
--- a/dgraph/cmd/server/run.go
+++ b/dgraph/cmd/server/run.go
@@ -311,6 +311,7 @@ func run() {
 	x.Init(edgraph.Config.DebugMode)
 	x.Config.QueryEdgeLimit = cast.ToUint64(Server.Conf.GetString("query_edge_limit"))
 
+	x.PrintVersion()
 	edgraph.InitServerState()
 	defer func() {
 		x.Check(edgraph.State.Dispose())
diff --git a/dgraph/cmd/version/run.go b/dgraph/cmd/version/run.go
index eb300d9a..49955b2a 100644
--- a/dgraph/cmd/version/run.go
+++ b/dgraph/cmd/version/run.go
@@ -8,6 +8,8 @@
 package version
 
 import (
+	"os"
+
 	"github.com/spf13/cobra"
 
 	"github.com/dgraph-io/dgraph/x"
@@ -21,7 +23,8 @@ func init() {
 		Short: "Prints the dgraph version details",
 		Long:  "Version prints the dgraph version as reported by the build details.",
 		Run: func(cmd *cobra.Command, args []string) {
-			x.PrintVersionOnly()
+			x.PrintVersion()
+			os.Exit(0)
 		},
 	}
 }
diff --git a/dgraph/cmd/zero/run.go b/dgraph/cmd/zero/run.go
index 4cb3680e..bcb6e027 100644
--- a/dgraph/cmd/zero/run.go
+++ b/dgraph/cmd/zero/run.go
@@ -130,6 +130,7 @@ func (st *state) serveGRPC(l net.Listener, wg *sync.WaitGroup, store *raftwal.Di
 }
 
 func run() {
+	x.PrintVersion()
 	opts = options{
 		bindall:           Zero.Conf.GetBool("bindall"),
 		myAddr:            Zero.Conf.GetString("my"),
diff --git a/x/init.go b/x/init.go
index 646fc811..c3a7597f 100644
--- a/x/init.go
+++ b/x/init.go
@@ -9,7 +9,6 @@ package x
 
 import (
 	"fmt"
-	"os"
 )
 
 var (
@@ -67,9 +66,8 @@ Licensed under Apache 2.0 + Commons Clause. Copyright 2015-2018 Dgraph Labs, Inc
 }
 
 // PrintVersionOnly prints version and other helpful information if --version.
-func PrintVersionOnly() {
+func PrintVersion() {
 	fmt.Println(BuildDetails())
-	os.Exit(0)
 }
 
 func Version() string {
-- 
GitLab