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 "net/http" | 7 "net/http" |
8 "path/filepath" | 8 "path/filepath" |
9 "time" | 9 "time" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 defaultDbConnStr = db.GetConnectionString("readwrite", "", "", "") | 29 defaultDbConnStr = db.GetConnectionString("readwrite", "", "", "") |
30 | 30 |
31 graphiteServer = flag.String("graphite_server", "skia-monitoring:2003",
"Where is Graphite metrics ingestion server running.") | 31 graphiteServer = flag.String("graphite_server", "skia-monitoring:2003",
"Where is Graphite metrics ingestion server running.") |
32 port = flag.String("port", ":9000", "HTTP service address (e.g
., ':9000')") | 32 port = flag.String("port", ":9000", "HTTP service address (e.g
., ':9000')") |
33 local = flag.Bool("local", false, "Running locally if true. As
opposed to in production.") | 33 local = flag.Bool("local", false, "Running locally if true. As
opposed to in production.") |
34 staticDir = flag.String("static_dir", "./app", "Directory with stat
ic content to serve") | 34 staticDir = flag.String("static_dir", "./app", "Directory with stat
ic content to serve") |
35 tileStoreDir = flag.String("tile_store_dir", "/tmp/tileStore", "What d
irectory to look for tiles in.") | 35 tileStoreDir = flag.String("tile_store_dir", "/tmp/tileStore", "What d
irectory to look for tiles in.") |
36 imageDir = flag.String("image_dir", "/tmp/imagedir", "What directo
ry to store test and diff images in.") | 36 imageDir = flag.String("image_dir", "/tmp/imagedir", "What directo
ry to store test and diff images in.") |
37 gsBucketName = flag.String("gs_bucket", "chromium-skia-gm", "Name of t
he google storage bucket that holds uploaded images.") | 37 gsBucketName = flag.String("gs_bucket", "chromium-skia-gm", "Name of t
he google storage bucket that holds uploaded images.") |
38 dbConnStr = flag.String("db_conn_string", defaultDbConnStr, "MySQL
connection string for backend database. If 'local' is false the password in this
string will be substituted via the metadata server.") | 38 dbConnStr = flag.String("db_conn_string", defaultDbConnStr, "MySQL
connection string for backend database. If 'local' is false the password in this
string will be substituted via the metadata server.") |
39 sqlitePath = flag.String("sqlite_path", "./golden.db", "Filepath of
the embedded SQLite database. Requires 'local' to be set to true and 'mysql_conn
' to be empty to take effect.") | |
40 doOauth = flag.Bool("oauth", true, "Run through the OAuth 2.0 flo
w on startup, otherwise use a GCE service account.") | 39 doOauth = flag.Bool("oauth", true, "Run through the OAuth 2.0 flo
w on startup, otherwise use a GCE service account.") |
41 oauthCacheFile = flag.String("oauth_cache_file", "/home/perf/google_stor
age_token.data", "Path to the file where to cache cache the oauth credentials.") | 40 oauthCacheFile = flag.String("oauth_cache_file", "/home/perf/google_stor
age_token.data", "Path to the file where to cache cache the oauth credentials.") |
42 ) | 41 ) |
43 | 42 |
44 const ( | 43 const ( |
45 IMAGE_URL_PREFIX = "/img/" | 44 IMAGE_URL_PREFIX = "/img/" |
46 ) | 45 ) |
47 | 46 |
48 // TODO (stephana): Factor out to "go/login/login.go" | 47 // TODO (stephana): Factor out to "go/login/login.go" |
49 const ( | 48 const ( |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 clientSecret = metadata.MustGet(CLIENT_SECRET_METADATA_KEY) | 232 clientSecret = metadata.MustGet(CLIENT_SECRET_METADATA_KEY) |
234 redirectURL = "https://skiagold.com/oauth2callback/" | 233 redirectURL = "https://skiagold.com/oauth2callback/" |
235 } | 234 } |
236 login.Init(clientID, clientSecret, redirectURL, cookieSalt) | 235 login.Init(clientID, clientSecret, redirectURL, cookieSalt) |
237 | 236 |
238 // get the Oauthclient if necessary. | 237 // get the Oauthclient if necessary. |
239 client := getOAuthClient(*doOauth, *oauthCacheFile) | 238 client := getOAuthClient(*doOauth, *oauthCacheFile) |
240 | 239 |
241 // Get the expecations storage, the filediff storage and the tilestore. | 240 // Get the expecations storage, the filediff storage and the tilestore. |
242 diffStore := filediffstore.NewFileDiffStore(client, *imageDir, *gsBucket
Name, filediffstore.DEFAULT_GS_IMG_DIR_NAME, filediffstore.RECOMMENDED_WORKER_PO
OL_SIZE) | 241 diffStore := filediffstore.NewFileDiffStore(client, *imageDir, *gsBucket
Name, filediffstore.DEFAULT_GS_IMG_DIR_NAME, filediffstore.RECOMMENDED_WORKER_PO
OL_SIZE) |
243 » vdb := database.NewVersionedDB(db.GetConfig(*dbConnStr, *sqlitePath, *lo
cal)) | 242 » vdb := database.NewVersionedDB(db.GetConfig(*dbConnStr, *local)) |
244 expStore := expstorage.NewCachingExpectationStore(expstorage.NewSQLExpec
tationStore(vdb)) | 243 expStore := expstorage.NewCachingExpectationStore(expstorage.NewSQLExpec
tationStore(vdb)) |
245 tileStore := filetilestore.NewFileTileStore(*tileStoreDir, "golden", -1) | 244 tileStore := filetilestore.NewFileTileStore(*tileStoreDir, "golden", -1) |
246 | 245 |
247 // Initialize the Analyzer | 246 // Initialize the Analyzer |
248 imgFS := NewURLAwareFileServer(*imageDir, IMAGE_URL_PREFIX) | 247 imgFS := NewURLAwareFileServer(*imageDir, IMAGE_URL_PREFIX) |
249 analyzer = analysis.NewAnalyzer(expStore, tileStore, diffStore, imgFS.Ge
tURL, 5*time.Minute) | 248 analyzer = analysis.NewAnalyzer(expStore, tileStore, diffStore, imgFS.Ge
tURL, 5*time.Minute) |
250 | 249 |
251 router := mux.NewRouter() | 250 router := mux.NewRouter() |
252 | 251 |
253 // Wire up the resources. We use the 'rest' prefix to avoid any name | 252 // Wire up the resources. We use the 'rest' prefix to avoid any name |
(...skipping 16 matching lines...) Expand all Loading... |
270 // Everything else is served out of the static directory. | 269 // Everything else is served out of the static directory. |
271 router.PathPrefix("/").Handler(http.FileServer(http.Dir(*staticDir))) | 270 router.PathPrefix("/").Handler(http.FileServer(http.Dir(*staticDir))) |
272 | 271 |
273 // Send all requests to the router | 272 // Send all requests to the router |
274 http.Handle("/", router) | 273 http.Handle("/", router) |
275 | 274 |
276 // Start the server | 275 // Start the server |
277 glog.Infoln("Serving on http://127.0.0.1" + *port) | 276 glog.Infoln("Serving on http://127.0.0.1" + *port) |
278 glog.Fatal(http.ListenAndServe(*port, nil)) | 277 glog.Fatal(http.ListenAndServe(*port, nil)) |
279 } | 278 } |
OLD | NEW |