diff options
author | 2014-10-13 12:43:01 -0700 | |
---|---|---|
committer | 2014-10-13 12:43:01 -0700 | |
commit | a658d368defdc9b3dd176b8cfd018aaf061fe9a2 (patch) | |
tree | 12c02a91ffbf436cf96ebbc2b819bea5a505b5b5 /tools | |
parent | 96affcde22a675e3629b9da490bb45a0ab07fa2b (diff) |
bug_chomper: Make server's port configurable.
Make 'port' a flag so you can change it from the command line, making the
server more flexible and allowing us to change in which port it listen
to requests.
$ ./run_server.sh --port :8002
BUG=None
TEST=see above
R=borenet@google.com
Review URL: https://codereview.chromium.org/649663003
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/bug_chomper/run_server.sh | 1 | ||||
-rw-r--r-- | tools/bug_chomper/src/server/server.go | 13 |
2 files changed, 8 insertions, 6 deletions
diff --git a/tools/bug_chomper/run_server.sh b/tools/bug_chomper/run_server.sh index a6cb4531aa..76518afa73 100755 --- a/tools/bug_chomper/run_server.sh +++ b/tools/bug_chomper/run_server.sh @@ -20,4 +20,3 @@ if [[ ! -f oauth_client_secret.json ]]; then fi GOPATH="$GOPATH:$DIR" go run $DIR/src/server/server.go $@ - diff --git a/tools/bug_chomper/src/server/server.go b/tools/bug_chomper/src/server/server.go index a20c679107..fcd1ccc3ef 100644 --- a/tools/bug_chomper/src/server/server.go +++ b/tools/bug_chomper/src/server/server.go @@ -35,7 +35,6 @@ const ( issueComment = "Edited by BugChomper" oauthCallbackPath = "/oauth2callback" oauthConfigFile = "oauth_client_secret.json" - defaultPort = 8000 localHost = "127.0.0.1" maxSessionLen = time.Duration(3600 * time.Second) priorityPrefix = "Priority-" @@ -43,6 +42,11 @@ const ( cookieName = "BugChomperCookie" ) +// Flags: +var ( + port = flag.String("port", ":8000", "HTTP service address (e.g., ':8000')") +) + var ( scheme = "http" @@ -362,17 +366,16 @@ func main() { http.HandleFunc("/", handleRoot) http.HandleFunc(oauthCallbackPath, handleOAuth2Callback) http.Handle("/res/", http.FileServer(http.Dir(curdir))) - port := ":" + strconv.Itoa(defaultPort) - log.Println("Server is running at " + scheme + "://" + localHost + port) + log.Println("Server is running at " + scheme + "://" + localHost + *port) var err error if public { log.Println("WARNING: This server is not secure and should not be made " + "publicly accessible.") scheme = "https" - err = http.ListenAndServeTLS(port, certFile, keyFile, nil) + err = http.ListenAndServeTLS(*port, certFile, keyFile, nil) } else { scheme = "http" - err = http.ListenAndServe(localHost+port, nil) + err = http.ListenAndServe(localHost+*port, nil) } if err != nil { log.Println(err.Error()) |