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
29c93309
Commit
29c93309
authored
Jan 01, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes to config file loading
parent
ad4cf373
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
159 additions
and
39 deletions
+159
-39
.bra.toml
+1
-1
conf/grafana.dev.ini
+5
-5
conf/grafana.example.ini
+108
-0
grafana
+1
-1
pkg/cmd/web.go
+9
-3
pkg/setting/setting.go
+35
-29
No files found.
.bra.toml
View file @
29c93309
...
...
@@ -6,7 +6,7 @@ init_cmds = [
watch_all
=
true
watch_dirs
=
[
"$WORKDIR/pkg"
,
"$WORKDIR/
template
s"
,
"$WORKDIR/
grafana/src/view
s"
,
"$WORKDIR/conf"
,
]
watch_exts
=
[
".go"
,
".ini"
]
...
...
conf/grafana.ini
→
conf/grafana.
dev.
ini
View file @
29c93309
app_name
=
Grafana
Pro Server
app_mode
=
dev
app_name
=
Grafana
app_mode
=
dev
elopment
[server]
protocol
=
http
...
...
@@ -7,8 +7,8 @@ domain = localhost
root_url
=
%(protocol)s://%(domain)s:%(http_port)s/
http_addr
=
http_port
=
3000
ssh_port
=
22
router_logging
=
false
static_root_path
=
grafana/src
[session]
; Either "memory", "file", default is "memory"
...
...
@@ -16,11 +16,11 @@ provider = file
; Provider config options
; memory: not have any config yet
; file: session file path, e.g. `data/sessions`
; redis: config like redis server addr, poolSize, password, e.g. `127.0.0.1:6379,100,g
ogs
`
; redis: config like redis server addr, poolSize, password, e.g. `127.0.0.1:6379,100,g
rafana
`
; mysql: go-sql-driver/mysql dsn config string, e.g. `root:password@/session_table`
provider_config
=
data/sessions
; Session cookie name
cookie_name
=
grafana_
pro_
sess
cookie_name
=
grafana_sess
; If you use session in https only, default is false
cookie_secure
=
false
; Enable set cookie, default is true
...
...
conf/grafana.example.ini
0 → 100644
View file @
29c93309
app_name
=
Grafana
app_mode
=
development
[server]
protocol
=
http
domain
=
localhost
root_url
=
%(protocol)s://%(domain)s:%(http_port)s/
http_addr
=
http_port
=
3000
router_logging
=
false
static_root_path
=
public
[session]
; Either "memory", "file", default is "memory"
provider
=
file
; Provider config options
; memory: not have any config yet
; file: session file path, e.g. `data/sessions`
; redis: config like redis server addr, poolSize, password, e.g. `127.0.0.1:6379,100,grafana`
; mysql: go-sql-driver/mysql dsn config string, e.g. `root:password@/session_table`
provider_config
=
data/sessions
; Session cookie name
cookie_name
=
grafana_sess
; If you use session in https only, default is false
cookie_secure
=
false
; Enable set cookie, default is true
enable_set_cookie
=
true
; Session GC time interval, default is 86400
gc_time_interval
=
86400
; Session life time, default is 86400
session_life_time
=
86400
; session id hash func, Either "sha1", "sha256" or "md5" default is sha1
session_id_hashfunc
=
sha1
; Session hash key, default is use random string
session_id_hashkey
=
[oauth]
enabled
=
true
[oauth.github]
enabled
=
true
client_id
=
de054205006b9baa2e17
client_secret
=
72b7ea52d9f1096fdf36cea95e95362a307e0322
scopes
=
user:email
auth_url
=
https://github.com/login/oauth/authorize
token_url
=
https://github.com/login/oauth/access_token
[oauth.google]
enabled
=
true
client_id
=
106011922963-4pvl05e9urtrm8bbqr0vouosj3e8p8kb.apps.googleusercontent.com
client_secret
=
K2evIa4QhfbhhAm3SO72t2Zv
scopes
=
https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
auth_url
=
https://accounts.google.com/o/oauth2/auth
token_url
=
https://accounts.google.com/o/oauth2/token
[database]
; Either "mysql", "postgres" or "sqlite3", it's your choice
type
=
sqlite3
host
=
127.0.0.1:3306
name
=
grafana
user
=
root
PASSWD
=
; For "postgres" only, either "disable", "require" or "verify-full"
ssl_mode
=
disable
; For "sqlite3" only
path
=
data/grafana.db
; [database]
; ; Either "mysql", "postgres" or "sqlite3", it's your choice
; type = postgres
; host = 127.0.0.1:5432
; name = grafana
; user = grafana
; password = grafana
; ; For "postgres" only, either "disable", "require" or "verify-full"
; ssl_mode = disable
; ; For "sqlite3" only
; path = data/grafana.db
;
[log]
root_path
=
; Either "console", "file", "conn", "smtp" or "database", default is "console"
; Use comma to separate multiple modes, e.g. "console, file"
mode
=
console
; Buffer length of channel, keep it as it is if you don't know what it is.
buffer_len
=
10000
; Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "Trace"
level
=
Trace
; For "console" mode only
[log.console]
level
=
; For "file" mode only
[log.file]
level
=
; This enables automated log rotate(switch of following options), default is true
log_rotate
=
true
; Max line number of single file, default is 1000000
max_lines
=
1000000
; Max size shift of single file, default is 28 means 1 << 28, 256MB
max_lines_shift
=
28
; Segment log daily, default is true
daily_rotate
=
true
; Expired days of log file(delete after max days), default is 7
max_days
=
7
grafana
@
7c72705b
Subproject commit
33e3fc70b286e0a1ebee901006e8f70b63b69198
Subproject commit
7c72705bc5418ddf7030b3b50e86b236bd07e1fc
pkg/cmd/web.go
View file @
29c93309
...
...
@@ -25,7 +25,13 @@ var CmdWeb = cli.Command{
Usage
:
"grafana web"
,
Description
:
"Starts Grafana backend & web server"
,
Action
:
runWeb
,
Flags
:
[]
cli
.
Flag
{},
Flags
:
[]
cli
.
Flag
{
cli
.
StringFlag
{
Name
:
"config"
,
Value
:
"grafana.ini"
,
Usage
:
"path to config file"
,
},
},
}
func
newMacaron
()
*
macaron
.
Macaron
{
...
...
@@ -61,8 +67,8 @@ func mapStatic(m *macaron.Macaron, dir string, prefix string) {
))
}
func
runWeb
(
*
cli
.
Context
)
{
log
.
Info
(
"Starting Grafana
-Pro v.2
-alpha"
)
func
runWeb
(
c
*
cli
.
Context
)
{
log
.
Info
(
"Starting Grafana
2.0
-alpha"
)
setting
.
NewConfigContext
()
setting
.
InitServices
()
...
...
pkg/setting/setting.go
View file @
29c93309
...
...
@@ -57,6 +57,7 @@ var (
SessionOptions
session
.
Options
// Global setting objects.
WorkDir
string
Cfg
*
goconfig
.
ConfigFile
ConfRootPath
string
CustomPath
string
// Custom directory path.
...
...
@@ -74,42 +75,47 @@ func init() {
log
.
NewLogger
(
0
,
"console"
,
`{"level": 0}`
)
}
func
WorkDir
()
(
string
,
error
)
{
p
,
err
:=
filepath
.
Abs
(
"."
)
if
err
!=
nil
{
return
""
,
err
}
return
p
,
nil
func
getWorkDir
()
string
{
p
,
_
:=
filepath
.
Abs
(
"."
)
return
p
}
func
NewConfigContext
()
{
workDir
,
err
:=
WorkDir
()
if
err
!=
nil
{
log
.
Fatal
(
4
,
"Fail to get work directory: %v"
,
err
)
}
ConfRootPath
=
path
.
Join
(
workDir
,
"conf"
)
func
findConfigFile
()
string
{
WorkDir
=
getWorkDir
()
ConfRootPath
=
path
.
Join
(
WorkDir
,
"conf"
)
Cfg
,
err
=
goconfig
.
LoadConfigFile
(
path
.
Join
(
workDir
,
"conf/grafana.ini"
))
if
err
!=
nil
{
log
.
Fatal
(
4
,
"Fail to parse '%v/conf/grafana.ini': %v"
,
workDir
,
err
)
configFile
:=
path
.
Join
(
ConfRootPath
,
"grafana.ini"
)
//log.Info("Looking for config file: %v", configFile)
if
com
.
IsFile
(
configFile
)
{
return
configFile
}
configFile
=
path
.
Join
(
ConfRootPath
,
"grafana.dev.ini"
)
//log.Info("Looking for config file: %v", configFile)
if
com
.
IsFile
(
configFile
)
{
return
configFile
}
configFile
=
path
.
Join
(
ConfRootPath
,
"grafana.example.ini"
)
//log.Info("Looking for config file: %v", configFile)
if
com
.
IsFile
(
configFile
)
{
return
configFile
}
CustomPath
=
os
.
Getenv
(
"GRAFANA_CONF"
)
log
.
Fatal
(
3
,
"Could not find any config file"
)
return
""
}
if
len
(
CustomPath
)
==
0
{
CustomPath
=
path
.
Join
(
workDir
,
"custom"
)
}
func
NewConfigContext
()
{
configFile
:=
findConfigFile
()
log
.
Info
(
"Loading config file: %v"
,
configFile
)
var
err
error
cfgPath
:=
path
.
Join
(
CustomPath
,
"conf/grafana.ini"
)
if
com
.
IsFile
(
cfgPath
)
{
if
err
=
Cfg
.
AppendFiles
(
cfgPath
);
err
!=
nil
{
log
.
Fatal
(
4
,
"Fail to load custom 'conf/grafana.ini': %v"
,
err
)
}
}
else
{
log
.
Warn
(
"No custom 'conf/grafana.ini'"
)
Cfg
,
err
=
goconfig
.
LoadConfigFile
(
configFile
)
if
err
!=
nil
{
log
.
Fatal
(
4
,
"Fail to parse %v, error: %v"
,
configFile
,
err
)
}
AppName
=
Cfg
.
MustValue
(
""
,
"app_name"
,
"Grafana
Pro
"
)
AppName
=
Cfg
.
MustValue
(
""
,
"app_name"
,
"Grafana"
)
AppUrl
=
Cfg
.
MustValue
(
"server"
,
"root_url"
,
"http://localhost:3000/"
)
if
AppUrl
[
len
(
AppUrl
)
-
1
]
!=
'/'
{
AppUrl
+=
"/"
...
...
@@ -137,14 +143,14 @@ func NewConfigContext() {
HttpPort
=
port
}
StaticRootPath
=
Cfg
.
MustValue
(
"server"
,
"static_root_path"
,
path
.
Join
(
workDir
,
"grafana/src
"
))
StaticRootPath
=
Cfg
.
MustValue
(
"server"
,
"static_root_path"
,
path
.
Join
(
WorkDir
,
"webapp
"
))
RouterLogging
=
Cfg
.
MustBool
(
"server"
,
"router_logging"
,
false
)
// PhantomJS rendering
ImagesDir
=
"data/png"
PhantomDir
=
"_vendor/phantomjs"
LogRootPath
=
Cfg
.
MustValue
(
"log"
,
"root_path"
,
path
.
Join
(
w
orkDir
,
"/data/log"
))
LogRootPath
=
Cfg
.
MustValue
(
"log"
,
"root_path"
,
path
.
Join
(
W
orkDir
,
"/data/log"
))
}
func
initSessionService
()
{
...
...
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