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
d7ee4b45
Commit
d7ee4b45
authored
Nov 26, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing files
parent
a492ecef
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
1 deletions
+130
-1
.gitignore
+1
-1
Makefile
+8
-0
pkg/cmd/grafana-pro/grafana-pro.go
+24
-0
pkg/cmd/grafana-pro/web.go
+97
-0
No files found.
.gitignore
View file @
d7ee4b45
...
...
@@ -17,4 +17,4 @@ config.js
data/sessions
data/*.db
data/log
grafana-pro
/
grafana-pro
Makefile
0 → 100644
View file @
d7ee4b45
all
:
build
build
:
go build ../pkg/cmd/grafana-pro/
pkg/cmd/grafana-pro/grafana-pro.go
0 → 100644
View file @
d7ee4b45
package
main
import
(
"os"
"runtime"
"github.com/codegangsta/cli"
)
const
APP_VER
=
"0.1.0 Alpha"
func
init
()
{
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
}
func
main
()
{
app
:=
cli
.
NewApp
()
app
.
Name
=
"Grafana Pro"
app
.
Usage
=
"Grafana Pro Service"
app
.
Version
=
APP_VER
app
.
Commands
=
[]
cli
.
Command
{
CmdWeb
}
app
.
Flags
=
append
(
app
.
Flags
,
[]
cli
.
Flag
{}
...
)
app
.
Run
(
os
.
Args
)
}
pkg/cmd/grafana-pro/web.go
0 → 100644
View file @
d7ee4b45
// Copyright 2014 Unknwon
// Copyright 2014 Torkel Ödegaard
package
main
import
(
"fmt"
"net/http"
"path"
"github.com/Unknwon/macaron"
"github.com/codegangsta/cli"
"github.com/macaron-contrib/session"
"github.com/torkelo/grafana-pro/pkg/log"
"github.com/torkelo/grafana-pro/pkg/middleware"
"github.com/torkelo/grafana-pro/pkg/routes"
"github.com/torkelo/grafana-pro/pkg/setting"
"github.com/torkelo/grafana-pro/pkg/social"
"github.com/torkelo/grafana-pro/pkg/stores/sqlstore"
)
var
CmdWeb
=
cli
.
Command
{
Name
:
"web"
,
Usage
:
"Start Grafana Pro web server"
,
Description
:
`Start Grafana Pro server`
,
Action
:
runWeb
,
Flags
:
[]
cli
.
Flag
{},
}
func
newMacaron
()
*
macaron
.
Macaron
{
m
:=
macaron
.
New
()
m
.
Use
(
middleware
.
Logger
())
m
.
Use
(
macaron
.
Recovery
())
mapStatic
(
m
,
"public"
,
"public"
)
mapStatic
(
m
,
"public/app"
,
"app"
)
mapStatic
(
m
,
"public/img"
,
"img"
)
m
.
Use
(
session
.
Sessioner
(
session
.
Options
{
Provider
:
setting
.
SessionProvider
,
Config
:
*
setting
.
SessionConfig
,
}))
m
.
Use
(
macaron
.
Renderer
(
macaron
.
RenderOptions
{
Directory
:
path
.
Join
(
setting
.
StaticRootPath
,
"views"
),
IndentJSON
:
macaron
.
Env
!=
macaron
.
PROD
,
Delims
:
macaron
.
Delims
{
Left
:
"[["
,
Right
:
"]]"
},
}))
m
.
Use
(
middleware
.
GetContextHandler
())
return
m
}
func
mapStatic
(
m
*
macaron
.
Macaron
,
dir
string
,
prefix
string
)
{
m
.
Use
(
macaron
.
Static
(
path
.
Join
(
setting
.
StaticRootPath
,
dir
),
macaron
.
StaticOptions
{
SkipLogging
:
true
,
Prefix
:
prefix
,
},
))
}
func
runWeb
(
*
cli
.
Context
)
{
log
.
Info
(
"Starting Grafana-Pro v.2-alpha"
)
setting
.
NewConfigContext
()
setting
.
InitServices
()
sqlstore
.
Init
()
social
.
NewOAuthService
()
// init database
sqlstore
.
LoadModelsConfig
()
if
err
:=
sqlstore
.
NewEngine
();
err
!=
nil
{
log
.
Fatal
(
4
,
"fail to initialize orm engine: %v"
,
err
)
}
m
:=
newMacaron
()
routes
.
Register
(
m
)
var
err
error
listenAddr
:=
fmt
.
Sprintf
(
"%s:%s"
,
setting
.
HttpAddr
,
setting
.
HttpPort
)
log
.
Info
(
"Listen: %v://%s%s"
,
setting
.
Protocol
,
listenAddr
,
setting
.
AppSubUrl
)
switch
setting
.
Protocol
{
case
setting
.
HTTP
:
err
=
http
.
ListenAndServe
(
listenAddr
,
m
)
case
setting
.
HTTPS
:
err
=
http
.
ListenAndServeTLS
(
listenAddr
,
setting
.
CertFile
,
setting
.
KeyFile
,
m
)
default
:
log
.
Fatal
(
4
,
"Invalid protocol: %s"
,
setting
.
Protocol
)
}
if
err
!=
nil
{
log
.
Fatal
(
4
,
"Fail to start server: %v"
,
err
)
}
}
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