OLD | NEW |
1 package main | 1 package main |
2 | 2 |
3 import ( | 3 import ( |
4 "encoding/json" | 4 "encoding/json" |
5 "flag" | 5 "flag" |
6 "fmt" | 6 "fmt" |
7 ehtml "html" | 7 ehtml "html" |
8 "html/template" | 8 "html/template" |
9 "math/rand" | 9 "math/rand" |
10 "net/http" | 10 "net/http" |
11 "os" | 11 "os" |
12 "path/filepath" | 12 "path/filepath" |
13 "regexp" | 13 "regexp" |
14 "runtime" | 14 "runtime" |
15 "strconv" | 15 "strconv" |
16 "strings" | 16 "strings" |
17 "time" | 17 "time" |
18 ) | 18 ) |
19 | 19 |
20 import ( | 20 import ( |
21 "github.com/fiorix/go-web/autogzip" | 21 "github.com/fiorix/go-web/autogzip" |
22 "github.com/golang/glog" | 22 "github.com/golang/glog" |
23 ) | 23 ) |
24 | 24 |
25 import ( | 25 import ( |
26 "skia.googlesource.com/buildbot.git/go/common" | 26 "skia.googlesource.com/buildbot.git/go/common" |
| 27 "skia.googlesource.com/buildbot.git/go/database" |
27 "skia.googlesource.com/buildbot.git/go/gitinfo" | 28 "skia.googlesource.com/buildbot.git/go/gitinfo" |
28 "skia.googlesource.com/buildbot.git/go/login" | 29 "skia.googlesource.com/buildbot.git/go/login" |
29 "skia.googlesource.com/buildbot.git/go/metadata" | 30 "skia.googlesource.com/buildbot.git/go/metadata" |
30 "skia.googlesource.com/buildbot.git/go/util" | 31 "skia.googlesource.com/buildbot.git/go/util" |
31 "skia.googlesource.com/buildbot.git/perf/go/activitylog" | 32 "skia.googlesource.com/buildbot.git/perf/go/activitylog" |
32 "skia.googlesource.com/buildbot.git/perf/go/alerting" | 33 "skia.googlesource.com/buildbot.git/perf/go/alerting" |
33 "skia.googlesource.com/buildbot.git/perf/go/annotate" | 34 "skia.googlesource.com/buildbot.git/perf/go/annotate" |
34 "skia.googlesource.com/buildbot.git/perf/go/clustering" | 35 "skia.googlesource.com/buildbot.git/perf/go/clustering" |
35 "skia.googlesource.com/buildbot.git/perf/go/config" | 36 "skia.googlesource.com/buildbot.git/perf/go/config" |
36 "skia.googlesource.com/buildbot.git/perf/go/db" | 37 "skia.googlesource.com/buildbot.git/perf/go/db" |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 | 1052 |
1052 func makeResourceHandler() func(http.ResponseWriter, *http.Request) { | 1053 func makeResourceHandler() func(http.ResponseWriter, *http.Request) { |
1053 fileServer := http.FileServer(http.Dir("./")) | 1054 fileServer := http.FileServer(http.Dir("./")) |
1054 return func(w http.ResponseWriter, r *http.Request) { | 1055 return func(w http.ResponseWriter, r *http.Request) { |
1055 w.Header().Add("Cache-Control", string(300)) | 1056 w.Header().Add("Cache-Control", string(300)) |
1056 fileServer.ServeHTTP(w, r) | 1057 fileServer.ServeHTTP(w, r) |
1057 } | 1058 } |
1058 } | 1059 } |
1059 | 1060 |
1060 func main() { | 1061 func main() { |
| 1062 // Setup DB flags. |
| 1063 database.SetupFlags(db.PROD_DB_HOST, db.PROD_DB_PORT, database.USER_RW,
db.PROD_DB_NAME) |
| 1064 |
1061 common.InitWithMetrics("skiaperf", *graphiteServer) | 1065 common.InitWithMetrics("skiaperf", *graphiteServer) |
1062 Init() | 1066 Init() |
1063 » db.Init(db.ProdDatabaseConfig(*local)) | 1067 » conf, err := database.ConfigFromFlagsAndMetadata(*local, db.MigrationSte
ps()) |
| 1068 » if err != nil { |
| 1069 » » glog.Fatal(err) |
| 1070 » } |
| 1071 » db.Init(conf) |
1064 stats.Start(nanoTileStore, git) | 1072 stats.Start(nanoTileStore, git) |
1065 alerting.Start(nanoTileStore, *apikey) | 1073 alerting.Start(nanoTileStore, *apikey) |
1066 | 1074 |
1067 // By default use a set of credentials setup for localhost access. | 1075 // By default use a set of credentials setup for localhost access. |
1068 var cookieSalt = "notverysecret" | 1076 var cookieSalt = "notverysecret" |
1069 var clientID = "31977622648-1873k0c1e5edaka4adpv1ppvhr5id3qm.apps.google
usercontent.com" | 1077 var clientID = "31977622648-1873k0c1e5edaka4adpv1ppvhr5id3qm.apps.google
usercontent.com" |
1070 var clientSecret = "cw0IosPu4yjaG2KWmppj2guj" | 1078 var clientSecret = "cw0IosPu4yjaG2KWmppj2guj" |
1071 var redirectURL = fmt.Sprintf("http://localhost%s/oauth2callback/", *por
t) | 1079 var redirectURL = fmt.Sprintf("http://localhost%s/oauth2callback/", *por
t) |
1072 if !*local { | 1080 if !*local { |
1073 cookieSalt = metadata.MustGet(COOKIESALT_METADATA_KEY) | 1081 cookieSalt = metadata.MustGet(COOKIESALT_METADATA_KEY) |
(...skipping 26 matching lines...) Expand all Loading... |
1100 http.HandleFunc("/compare/", autogzip.HandleFunc(compareHandler)) | 1108 http.HandleFunc("/compare/", autogzip.HandleFunc(compareHandler)) |
1101 http.HandleFunc("/calc/", autogzip.HandleFunc(calcHandler)) | 1109 http.HandleFunc("/calc/", autogzip.HandleFunc(calcHandler)) |
1102 http.HandleFunc("/help/", autogzip.HandleFunc(helpHandler)) | 1110 http.HandleFunc("/help/", autogzip.HandleFunc(helpHandler)) |
1103 http.HandleFunc("/oauth2callback/", login.OAuth2CallbackHandler) | 1111 http.HandleFunc("/oauth2callback/", login.OAuth2CallbackHandler) |
1104 http.HandleFunc("/logout/", login.LogoutHandler) | 1112 http.HandleFunc("/logout/", login.LogoutHandler) |
1105 http.HandleFunc("/loginstatus/", login.StatusHandler) | 1113 http.HandleFunc("/loginstatus/", login.StatusHandler) |
1106 | 1114 |
1107 glog.Infoln("Ready to serve.") | 1115 glog.Infoln("Ready to serve.") |
1108 glog.Fatal(http.ListenAndServe(*port, nil)) | 1116 glog.Fatal(http.ListenAndServe(*port, nil)) |
1109 } | 1117 } |
OLD | NEW |