Skip to content

Commit

Permalink
Add flag for custom ports
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Alexander committed Jul 1, 2015
1 parent 39517f9 commit 6509f6f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doduc-server/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"fmt"
"log"
"net"
Expand All @@ -18,11 +19,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
}

func main() {
flagPort := flag.Uint("port", 18768, "the port to listen on")
flag.Parse()
logFile, err := os.OpenFile("doduc-server.log", os.O_APPEND|os.O_CREATE, 0200)
if err != nil {
log.Fatal("unable to open log file")
}
log.SetOutput(logFile)
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":18768", nil))
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *flagPort), nil))
}

0 comments on commit 6509f6f

Please sign in to comment.