2017-06-27 20:40:17 +03:00
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
2016-05-18 00:19:28 +03:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2017-06-27 20:40:17 +03:00
|
|
|
// Devapp is the server running dev.golang.org. It shows open bugs and code
|
|
|
|
// reviews and other useful dashboards for Go developers.
|
|
|
|
package main
|
2016-05-18 00:19:28 +03:00
|
|
|
|
|
|
|
import (
|
2017-06-27 20:40:17 +03:00
|
|
|
"context"
|
|
|
|
"flag"
|
2017-03-14 10:48:32 +03:00
|
|
|
"log"
|
2016-05-18 00:19:28 +03:00
|
|
|
"net/http"
|
2017-06-27 20:40:17 +03:00
|
|
|
"os"
|
2016-05-18 00:19:28 +03:00
|
|
|
|
2021-10-26 00:22:12 +03:00
|
|
|
"golang.org/x/build/internal/https"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
staticDir = flag.String("static-dir", "./static/", "location of static directory relative to binary location")
|
|
|
|
templateDir = flag.String("template-dir", "./templates/", "location of templates directory relative to binary location")
|
|
|
|
reload = flag.Bool("reload", false, "reload content on each page load")
|
2016-05-18 00:19:28 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2017-06-27 20:40:17 +03:00
|
|
|
flag.Usage = func() {
|
|
|
|
os.Stderr.WriteString("devapp generates the dashboard that powers dev.golang.org.\n")
|
|
|
|
flag.PrintDefaults()
|
2016-05-18 00:19:28 +03:00
|
|
|
}
|
2017-06-27 20:40:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2021-10-26 00:22:12 +03:00
|
|
|
https.RegisterFlags(flag.CommandLine)
|
2017-06-27 20:40:17 +03:00
|
|
|
flag.Parse()
|
|
|
|
|
2019-10-07 16:58:01 +03:00
|
|
|
s := newServer(http.NewServeMux(), *staticDir, *templateDir, *reload)
|
2017-07-06 05:24:05 +03:00
|
|
|
ctx := context.Background()
|
2018-08-03 00:55:42 +03:00
|
|
|
if err := s.initCorpus(ctx); err != nil {
|
|
|
|
log.Fatalf("Could not init corpus: %v", err)
|
|
|
|
}
|
2017-07-06 05:24:05 +03:00
|
|
|
go s.corpusUpdateLoop(ctx)
|
2017-06-28 01:53:32 +03:00
|
|
|
|
2021-10-26 00:22:12 +03:00
|
|
|
log.Fatalln(https.ListenAndServe(ctx, s))
|
2016-05-18 00:19:28 +03:00
|
|
|
}
|