From 1f4e91bb74025ff856e28df3201baa4ad0e4316e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E6=96=87=E5=93=81?= Date: Sat, 27 Jan 2018 12:42:14 +0800 Subject: [PATCH] godep change to dep --- .gitignore | 2 +- Godeps/Godeps.json | 69 ------------------------------------ Godeps/Readme | 5 --- Gopkg.lock | 87 ++++++++++++++++++++++++++++++++++++++++++++++ Gopkg.toml | 46 ++++++++++++++++++++++++ g.go | 15 ++++++-- main.go | 9 +++-- 7 files changed, 153 insertions(+), 80 deletions(-) delete mode 100644 Godeps/Godeps.json delete mode 100644 Godeps/Readme create mode 100644 Gopkg.lock create mode 100644 Gopkg.toml diff --git a/.gitignore b/.gitignore index c7cce5a..b5b113c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ alex -Godeps/_workspace +vendor diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json deleted file mode 100644 index dafb74b..0000000 --- a/Godeps/Godeps.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "ImportPath": "alex", - "GoVersion": "go1.4", - "GodepVersion": "v67", - "Deps": [ - { - "ImportPath": "github.com/codegangsta/inject", - "Comment": "v1.0-rc1-10-g33e0aa1", - "Rev": "33e0aa1cb7c019ccc3fbe049a8262a6403d30504" - }, - { - "ImportPath": "github.com/go-martini/martini", - "Comment": "v1.0-183-gb174c4f", - "Rev": "b174c4f35f9f3805e960be6286d888bc79534755" - }, - { - "ImportPath": "github.com/martini-contrib/render", - "Rev": "ec18f8345a1181146728238980606fb1d6f40e8c" - }, - { - "ImportPath": "github.com/oxtoacart/bpool", - "Rev": "4e1c5567d7c2dd59fa4c7c83d34c2f3528b025d6" - }, - { - "ImportPath": "github.com/shirou/gopsutil/internal/common", - "Comment": "v2.0.0-29-gbae75fa", - "Rev": "bae75faa5ad1212d3e80f11f5e9cd147c6be9198" - }, - { - "ImportPath": "github.com/shirou/gopsutil/load", - "Comment": "v2.0.0-29-gbae75fa", - "Rev": "bae75faa5ad1212d3e80f11f5e9cd147c6be9198" - }, - { - "ImportPath": "github.com/shirou/gopsutil/mem", - "Comment": "v2.0.0-29-gbae75fa", - "Rev": "bae75faa5ad1212d3e80f11f5e9cd147c6be9198" - }, - { - "ImportPath": "github.com/streadway/quantile", - "Rev": "b0c588724d25ae13f5afb3d90efec0edc636432b" - }, - { - "ImportPath": "github.com/tsenart/vegeta/lib", - "Comment": "v6.0.0-4-g166e305", - "Rev": "166e3050f5a8b2f6d3d2cb03e7baa430f019395d" - }, - { - "ImportPath": "gopkg.in/mgo.v2", - "Comment": "r2016.02.04-1-gb6e2fa3", - "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da" - }, - { - "ImportPath": "gopkg.in/mgo.v2/bson", - "Comment": "r2016.02.04-1-gb6e2fa3", - "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da" - }, - { - "ImportPath": "gopkg.in/mgo.v2/internal/sasl", - "Comment": "r2016.02.04-1-gb6e2fa3", - "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da" - }, - { - "ImportPath": "gopkg.in/mgo.v2/internal/scram", - "Comment": "r2016.02.04-1-gb6e2fa3", - "Rev": "b6e2fa371e64216a45e61072a96d4e3859f169da" - } - ] -} diff --git a/Godeps/Readme b/Godeps/Readme deleted file mode 100644 index 4cdaa53..0000000 --- a/Godeps/Readme +++ /dev/null @@ -1,5 +0,0 @@ -This directory tree is generated automatically by godep. - -Please do not edit. - -See https://github.com/tools/godep for more information. diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 0000000..b44a139 --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,87 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + name = "github.com/StackExchange/wmi" + packages = ["."] + revision = "5d049714c4a64225c3c79a7cf7d02f7fb5b96338" + +[[projects]] + name = "github.com/codegangsta/inject" + packages = ["."] + revision = "37d7f8432a3e684eef9b2edece76bdfa6ac85b39" + version = "v1.0-rc1" + +[[projects]] + name = "github.com/go-martini/martini" + packages = ["."] + revision = "49411a5b646861ad29a6ddd5351717a0a9c49b94" + version = "v1.0" + +[[projects]] + name = "github.com/go-ole/go-ole" + packages = [".","oleutil"] + revision = "0e87ea779d9deb219633b828a023b32e1244dd57" + version = "v1.2.0" + +[[projects]] + branch = "master" + name = "github.com/martini-contrib/render" + packages = ["."] + revision = "ec18f8345a1181146728238980606fb1d6f40e8c" + +[[projects]] + branch = "master" + name = "github.com/oxtoacart/bpool" + packages = ["."] + revision = "4e1c5567d7c2dd59fa4c7c83d34c2f3528b025d6" + +[[projects]] + name = "github.com/shirou/gopsutil" + packages = ["internal/common","load","mem"] + revision = "7ec06ec280df1dd1f08befc535049d49d63ae18a" + version = "v2.17.12" + +[[projects]] + branch = "master" + name = "github.com/streadway/quantile" + packages = ["."] + revision = "b0c588724d25ae13f5afb3d90efec0edc636432b" + +[[projects]] + name = "github.com/tsenart/vegeta" + packages = ["lib"] + revision = "9f28db162ce19bb52817af4fd9b5801b1f2772c5" + version = "v6.3.0" + +[[projects]] + branch = "master" + name = "golang.org/x/net" + packages = ["http2","http2/hpack","idna","lex/httplex"] + revision = "0ed95abb35c445290478a5348a7b38bb154135fd" + +[[projects]] + branch = "master" + name = "golang.org/x/sys" + packages = ["unix","windows"] + revision = "ff2a66f350cefa5c93a634eadb5d25bb60c85a9c" + +[[projects]] + branch = "master" + name = "golang.org/x/text" + packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable"] + revision = "e19ae1496984b1c655b8044a65c0300a3c878dd3" + +[[projects]] + branch = "v2" + name = "gopkg.in/mgo.v2" + packages = [".","bson","internal/json","internal/sasl","internal/scram"] + revision = "3f83fa5005286a7fe593b055f0d7771a7dce4655" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "82cbea74fa8d42a0bdb971e648bd742474a0c65ad695f10dae507fd00adfb0ed" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..502a2bc --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,46 @@ + +# Gopkg.toml example +# +# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" + + +[[constraint]] + name = "github.com/go-martini/martini" + version = "1.0.0" + +[[constraint]] + branch = "master" + name = "github.com/martini-contrib/render" + +[[constraint]] + name = "github.com/shirou/gopsutil" + version = "2.17.12" + +[[constraint]] + branch = "master" + name = "github.com/streadway/quantile" + +[[constraint]] + name = "github.com/tsenart/vegeta" + version = "6.3.0" + +[[constraint]] + branch = "v2" + name = "gopkg.in/mgo.v2" diff --git a/g.go b/g.go index a53a2f0..e5ca4c9 100644 --- a/g.go +++ b/g.go @@ -3,14 +3,18 @@ package main import ( "encoding/json" "flag" - "gopkg.in/mgo.v2" "log" "os" "runtime" + "strconv" + "strings" + + "gopkg.in/mgo.v2" ) // Web UI default Listen address -var G_AlexAddr = "0.0.0.0:8000" +var G_AlexHost = "0.0.0.0" +var G_AlexPort = 8000 // Job Storage Default Url var G_MongoUrl = "localhost:27017" @@ -60,7 +64,12 @@ func LoadConfig() { if err != nil { log.Panic("config file not valid json") } - G_AlexAddr = config.BindAddr + pairs := strings.Split(config.BindAddr, ":") + G_AlexHost = pairs[0] + G_AlexPort, err = strconv.Atoi(pairs[1]) + if err != nil { + log.Panic("port must be int") + } G_AlexTeams = config.Teams G_MongoUrl = config.MongoUrl G_ShowLayout = config.ShowLayout diff --git a/main.go b/main.go index bba417e..f4ce22d 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,12 @@ package main import ( + "fmt" + "html/template" + "os" + "github.com/go-martini/martini" "github.com/martini-contrib/render" - "html/template" ) func main() { @@ -57,5 +60,7 @@ func main() { r.Get("/metrics", GetBoomMetrics) }) // Let's fly - m.RunOnAddr(G_AlexAddr) + os.Setenv("HOST", G_AlexHost) + os.Setenv("PORT", fmt.Sprintf("%d", G_AlexPort)) + m.Run() }