Allow users to run the scouting app with HTTPS/LDAP
I find myself needing to experiment with getting the username from the
LDAP login that happens in our HTTPS version of the scouting app. This
patch exposes a new `//scouting:https` target to let me do just that.
This patch also updates the README to let other folks know how to run
it under HTTPS/LDAP.
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: Ib9f4b8626cb9adfe178ded2b43677d1dcd30da4f
diff --git a/scouting/webserver/main.go b/scouting/webserver/main.go
index a4d549a..8f4298b 100644
--- a/scouting/webserver/main.go
+++ b/scouting/webserver/main.go
@@ -9,6 +9,7 @@
"log"
"os"
"os/signal"
+ "strconv"
"syscall"
"time"
@@ -39,8 +40,23 @@
return &config, nil
}
+// Gets the default port to use for the webserver. If wrapped by
+// apache_wrapper(), we use the port dictated by the wrapper.
+func getDefaultPort() int {
+ port_str := os.Getenv("APACHE_WRAPPED_PORT")
+ if port_str != "" {
+ port, err := strconv.Atoi(port_str)
+ if err != nil {
+ log.Fatalf("Failed to parse \"%s\" as integer: %v", port_str, err)
+ }
+ return port
+ }
+
+ return 8080
+}
+
func main() {
- portPtr := flag.Int("port", 8080, "The port number to bind to.")
+ portPtr := flag.Int("port", getDefaultPort(), "The port number to bind to.")
dirPtr := flag.String("directory", ".", "The directory to serve at /.")
dbConfigPtr := flag.String("db_config", "",
"The postgres database JSON config. It needs the following keys: "+