From 6946f966b0a93c2a13bcf8156a31423a3e8d4bd1 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 1 Sep 2010 16:19:53 -0400 Subject: [PATCH] Add a port arg to the server. --- src/main.go | 5 +++-- src/server.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.go b/src/main.go index e5c8887..0a836e1 100644 --- a/src/main.go +++ b/src/main.go @@ -18,7 +18,8 @@ import ( func main() { flag.StringVar(&paths.JailRoot, "jail", "/", "Restrict file operations to this directory root") + var port *int = flag.Int("port", 8080, "Port to run the server on") flag.Parse() - fmt.Printf("Starting Armadillo with root:\n %v\n", paths.JailRoot) - server.RunFrontEnd() + fmt.Printf("Starting Armadillo on port %d with root:\n %v\n", *port, paths.JailRoot) + server.RunFrontEnd(*port) } diff --git a/src/server.go b/src/server.go index a99a951..a822212 100644 --- a/src/server.go +++ b/src/server.go @@ -75,12 +75,12 @@ func okResponse(connection *http.Conn, data interface{}) { } } -func RunFrontEnd() { +func RunFrontEnd(port int) { mux := http.NewServeMux() mux.HandleFunc("/", indexHandler) mux.Handle("/fe/", http.FileServer(kFrontEndFiles, "/fe/")) mux.HandleFunc("/service", serviceHandler) - error := http.ListenAndServe(":8084", mux) + error := http.ListenAndServe(fmt.Sprintf(":%d", port), mux) fmt.Printf("error %v", error) } -- 2.22.5