mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Added flag to display version number and exit
This commit is contained in:
@@ -86,10 +86,12 @@ go get github.com/grafana/grafana
|
|||||||
|
|
||||||
### Building the backend
|
### Building the backend
|
||||||
```
|
```
|
||||||
|
/usr/local/go/src/github.com/grafana/grafana/
|
||||||
cd $GOPATH/src/github.com/grafana/grafana
|
cd $GOPATH/src/github.com/grafana/grafana
|
||||||
go run build.go setup (only needed once to install godep)
|
go run build.go setup (only needed once to install godep)
|
||||||
godep restore (will pull down all golang lib dependencies in your current GOPATH)
|
godep restore (will pull down all golang lib dependencies in your current GOPATH)
|
||||||
go build .
|
go build -ldflags "-X main.build_date=`date +%Y-%m-%d` -X main.version=2.6.1 -X main.commit=`git rev-parse --verify HEAD`"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Building frontend assets
|
### Building frontend assets
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -27,6 +28,7 @@ import (
|
|||||||
var version = "master"
|
var version = "master"
|
||||||
var commit = "NA"
|
var commit = "NA"
|
||||||
var buildstamp string
|
var buildstamp string
|
||||||
|
var build_date string
|
||||||
|
|
||||||
var configFile = flag.String("config", "", "path to config file")
|
var configFile = flag.String("config", "", "path to config file")
|
||||||
var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory")
|
var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory")
|
||||||
@@ -38,6 +40,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
v := flag.Bool("v", false, "prints current version and exits")
|
||||||
|
flag.Parse()
|
||||||
|
if *v {
|
||||||
|
fmt.Printf("Version %s (commit: %s)\n", version, commit)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
buildstampInt64, _ := strconv.ParseInt(buildstamp, 10, 64)
|
buildstampInt64, _ := strconv.ParseInt(buildstamp, 10, 64)
|
||||||
|
|
||||||
setting.BuildVersion = version
|
setting.BuildVersion = version
|
||||||
|
|||||||
Reference in New Issue
Block a user