Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
c9ac762f
Commit
c9ac762f
authored
Oct 29, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: adds branch info to binary build
parent
dc961a82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
25 deletions
+27
-25
build.go
+9
-0
pkg/cmd/grafana-server/main.go
+7
-7
pkg/cmd/grafana-server/server.go
+8
-13
pkg/setting/setting.go
+3
-5
No files found.
build.go
View file @
c9ac762f
...
@@ -471,6 +471,7 @@ func ldflags() string {
...
@@ -471,6 +471,7 @@ func ldflags() string {
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.version=%s"
,
version
))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.version=%s"
,
version
))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.commit=%s"
,
getGitSha
()))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.commit=%s"
,
getGitSha
()))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.buildstamp=%d"
,
buildStamp
()))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.buildstamp=%d"
,
buildStamp
()))
b
.
WriteString
(
fmt
.
Sprintf
(
" -X main.buildBranch=%s"
,
getGitBranch
()))
return
b
.
String
()
return
b
.
String
()
}
}
...
@@ -518,6 +519,14 @@ func setBuildEnv() {
...
@@ -518,6 +519,14 @@ func setBuildEnv() {
}
}
}
}
func
getGitBranch
()
string
{
v
,
err
:=
runError
(
"git"
,
"rev-parse"
,
"--abbrev-ref"
,
"HEAD"
)
if
err
!=
nil
{
return
"master"
}
return
string
(
v
)
}
func
getGitSha
()
string
{
func
getGitSha
()
string
{
v
,
err
:=
runError
(
"git"
,
"rev-parse"
,
"--short"
,
"HEAD"
)
v
,
err
:=
runError
(
"git"
,
"rev-parse"
,
"--short"
,
"HEAD"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/cmd/grafana-server/main.go
View file @
c9ac762f
...
@@ -3,6 +3,8 @@ package main
...
@@ -3,6 +3,8 @@ package main
import
(
import
(
"flag"
"flag"
"fmt"
"fmt"
"net/http"
_
"net/http/pprof"
"os"
"os"
"os/signal"
"os/signal"
"runtime"
"runtime"
...
@@ -11,16 +13,12 @@ import (
...
@@ -11,16 +13,12 @@ import (
"syscall"
"syscall"
"time"
"time"
"net/http"
extensions
"github.com/grafana/grafana/pkg/extensions"
_
"net/http/pprof"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/setting"
extensions
"github.com/grafana/grafana/pkg/extensions"
_
"github.com/grafana/grafana/pkg/services/alerting/conditions"
_
"github.com/grafana/grafana/pkg/services/alerting/conditions"
_
"github.com/grafana/grafana/pkg/services/alerting/notifiers"
_
"github.com/grafana/grafana/pkg/services/alerting/notifiers"
"github.com/grafana/grafana/pkg/setting"
_
"github.com/grafana/grafana/pkg/tsdb/cloudwatch"
_
"github.com/grafana/grafana/pkg/tsdb/cloudwatch"
_
"github.com/grafana/grafana/pkg/tsdb/elasticsearch"
_
"github.com/grafana/grafana/pkg/tsdb/elasticsearch"
_
"github.com/grafana/grafana/pkg/tsdb/graphite"
_
"github.com/grafana/grafana/pkg/tsdb/graphite"
...
@@ -35,6 +33,7 @@ import (
...
@@ -35,6 +33,7 @@ import (
var
version
=
"5.0.0"
var
version
=
"5.0.0"
var
commit
=
"NA"
var
commit
=
"NA"
var
buildBranch
=
"master"
var
buildstamp
string
var
buildstamp
string
var
configFile
=
flag
.
String
(
"config"
,
""
,
"path to config file"
)
var
configFile
=
flag
.
String
(
"config"
,
""
,
"path to config file"
)
...
@@ -47,7 +46,7 @@ func main() {
...
@@ -47,7 +46,7 @@ func main() {
profilePort
:=
flag
.
Int
(
"profile-port"
,
6060
,
"Define custom port for profiling"
)
profilePort
:=
flag
.
Int
(
"profile-port"
,
6060
,
"Define custom port for profiling"
)
flag
.
Parse
()
flag
.
Parse
()
if
*
v
{
if
*
v
{
fmt
.
Printf
(
"Version %s (commit: %s
)
\n
"
,
version
,
commit
)
fmt
.
Printf
(
"Version %s (commit: %s
, branch: %s)
\n
"
,
version
,
commit
,
buildBranch
)
os
.
Exit
(
0
)
os
.
Exit
(
0
)
}
}
...
@@ -78,6 +77,7 @@ func main() {
...
@@ -78,6 +77,7 @@ func main() {
setting
.
BuildVersion
=
version
setting
.
BuildVersion
=
version
setting
.
BuildCommit
=
commit
setting
.
BuildCommit
=
commit
setting
.
BuildStamp
=
buildstampInt64
setting
.
BuildStamp
=
buildstampInt64
setting
.
BuildBranch
=
buildBranch
setting
.
IsEnterprise
=
extensions
.
IsEnterprise
setting
.
IsEnterprise
=
extensions
.
IsEnterprise
metrics
.
M_Grafana_Version
.
WithLabelValues
(
version
)
.
Set
(
1
)
metrics
.
M_Grafana_Version
.
WithLabelValues
(
version
)
.
Set
(
1
)
...
...
pkg/cmd/grafana-server/server.go
View file @
c9ac762f
...
@@ -12,24 +12,16 @@ import (
...
@@ -12,24 +12,16 @@ import (
"time"
"time"
"github.com/facebookgo/inject"
"github.com/facebookgo/inject"
"github.com/grafana/grafana/pkg/api"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/middleware"
_
"github.com/grafana/grafana/pkg/extensions"
"github.com/grafana/grafana/pkg/registry"
"golang.org/x/sync/errgroup"
"github.com/grafana/grafana/pkg/api"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/login"
"github.com/grafana/grafana/pkg/login"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/social"
// self registering services
_
"github.com/grafana/grafana/pkg/extensions"
_
"github.com/grafana/grafana/pkg/metrics"
_
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware"
_
"github.com/grafana/grafana/pkg/plugins"
_
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/registry"
_
"github.com/grafana/grafana/pkg/services/alerting"
_
"github.com/grafana/grafana/pkg/services/alerting"
_
"github.com/grafana/grafana/pkg/services/cleanup"
_
"github.com/grafana/grafana/pkg/services/cleanup"
_
"github.com/grafana/grafana/pkg/services/notifications"
_
"github.com/grafana/grafana/pkg/services/notifications"
...
@@ -37,7 +29,10 @@ import (
...
@@ -37,7 +29,10 @@ import (
_
"github.com/grafana/grafana/pkg/services/rendering"
_
"github.com/grafana/grafana/pkg/services/rendering"
_
"github.com/grafana/grafana/pkg/services/search"
_
"github.com/grafana/grafana/pkg/services/search"
_
"github.com/grafana/grafana/pkg/services/sqlstore"
_
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/social"
// self registering services
_
"github.com/grafana/grafana/pkg/tracing"
_
"github.com/grafana/grafana/pkg/tracing"
"golang.org/x/sync/errgroup"
)
)
func
NewGrafanaServer
()
*
GrafanaServerImpl
{
func
NewGrafanaServer
()
*
GrafanaServerImpl
{
...
@@ -159,7 +154,7 @@ func (g *GrafanaServerImpl) loadConfiguration() {
...
@@ -159,7 +154,7 @@ func (g *GrafanaServerImpl) loadConfiguration() {
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
g
.
log
.
Info
(
"Starting "
+
setting
.
ApplicationName
,
"version"
,
version
,
"commit"
,
commit
,
"compiled"
,
time
.
Unix
(
setting
.
BuildStamp
,
0
))
g
.
log
.
Info
(
"Starting "
+
setting
.
ApplicationName
,
"version"
,
version
,
"commit"
,
commit
,
"
branch"
,
buildBranch
,
"
compiled"
,
time
.
Unix
(
setting
.
BuildStamp
,
0
))
g
.
cfg
.
LogConfigSources
()
g
.
cfg
.
LogConfigSources
()
}
}
...
...
pkg/setting/setting.go
View file @
c9ac762f
...
@@ -13,15 +13,12 @@ import (
...
@@ -13,15 +13,12 @@ import (
"regexp"
"regexp"
"runtime"
"runtime"
"strings"
"strings"
"gopkg.in/ini.v1"
"github.com/go-macaron/session"
"time"
"time"
"github.com/go-macaron/session"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/util"
"gopkg.in/ini.v1"
)
)
type
Scheme
string
type
Scheme
string
...
@@ -49,6 +46,7 @@ var (
...
@@ -49,6 +46,7 @@ var (
// build
// build
BuildVersion
string
BuildVersion
string
BuildCommit
string
BuildCommit
string
BuildBranch
string
BuildStamp
int64
BuildStamp
int64
IsEnterprise
bool
IsEnterprise
bool
ApplicationName
string
ApplicationName
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment