2014-08-08 05:35:15 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2015-03-03 10:14:58 -06:00
|
|
|
"os/signal"
|
2014-10-04 06:33:20 -05:00
|
|
|
"runtime"
|
2015-01-05 03:46:58 -06:00
|
|
|
"strconv"
|
2014-08-08 05:35:15 -05:00
|
|
|
|
2015-02-05 03:37:13 -06:00
|
|
|
"github.com/grafana/grafana/pkg/cmd"
|
|
|
|
"github.com/grafana/grafana/pkg/log"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
2014-11-28 04:51:34 -06:00
|
|
|
|
|
|
|
"github.com/codegangsta/cli"
|
2014-08-08 05:35:15 -05:00
|
|
|
)
|
|
|
|
|
2015-01-05 03:46:58 -06:00
|
|
|
var version = "master"
|
|
|
|
var commit = "NA"
|
|
|
|
var buildstamp string
|
2014-08-08 05:35:15 -05:00
|
|
|
|
2014-10-04 06:33:20 -05:00
|
|
|
func init() {
|
|
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
}
|
2014-08-08 05:35:15 -05:00
|
|
|
|
2014-10-04 06:33:20 -05:00
|
|
|
func main() {
|
2015-01-05 03:46:58 -06:00
|
|
|
buildstampInt64, _ := strconv.ParseInt(buildstamp, 10, 64)
|
|
|
|
|
|
|
|
setting.BuildVersion = version
|
|
|
|
setting.BuildCommit = commit
|
|
|
|
setting.BuildStamp = buildstampInt64
|
|
|
|
|
2015-03-03 10:14:58 -06:00
|
|
|
go func() {
|
|
|
|
c := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(c, os.Interrupt)
|
|
|
|
<-c
|
|
|
|
os.Exit(0)
|
|
|
|
}()
|
|
|
|
|
2014-10-04 06:33:20 -05:00
|
|
|
app := cli.NewApp()
|
2014-12-31 12:02:00 -06:00
|
|
|
app.Name = "Grafana Backend"
|
|
|
|
app.Usage = "grafana web"
|
2015-01-05 03:46:58 -06:00
|
|
|
app.Version = version
|
2015-02-15 15:00:06 -06:00
|
|
|
app.Commands = []cli.Command{
|
2015-02-23 13:07:49 -06:00
|
|
|
cmd.ListOrgs,
|
|
|
|
cmd.CreateOrg,
|
|
|
|
cmd.DeleteOrg,
|
2015-02-15 15:00:06 -06:00
|
|
|
cmd.ImportDashboard,
|
2015-02-16 00:40:21 -06:00
|
|
|
cmd.ListDataSources,
|
|
|
|
cmd.CreateDataSource,
|
|
|
|
cmd.DescribeDataSource,
|
|
|
|
cmd.DeleteDataSource,
|
2015-02-15 15:00:06 -06:00
|
|
|
cmd.Web}
|
2015-02-15 12:48:39 -06:00
|
|
|
app.Flags = append(app.Flags, []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "config",
|
2015-02-15 15:57:49 -06:00
|
|
|
Usage: "path to grafana.ini config file",
|
2015-02-15 12:48:39 -06:00
|
|
|
},
|
2015-03-03 10:14:58 -06:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "pidfile",
|
|
|
|
Usage: "path to pidfile",
|
|
|
|
},
|
2015-02-15 12:48:39 -06:00
|
|
|
}...)
|
2015-03-03 10:14:58 -06:00
|
|
|
|
2014-10-04 06:33:20 -05:00
|
|
|
app.Run(os.Args)
|
2015-01-29 07:33:50 -06:00
|
|
|
|
|
|
|
log.Close()
|
2014-08-08 05:35:15 -05:00
|
|
|
}
|