Skip to content

Commit

Permalink
add address and port configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
LQR471814 committed Apr 15, 2022
1 parent c6502ef commit 5db4b97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.1.1 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
Expand Down
11 changes: 9 additions & 2 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package main

import (
"filesharing/server/api"
"flag"
"log"
"net"
"net/http"
"strconv"
"strings"

"github.com/google/uuid"
Expand All @@ -14,6 +16,11 @@ import (
)

func main() {
address := flag.String("addr", "0.0.0.0", "The address to host on")
port := flag.Int("port", 8080, "The port to listen on")

flag.Parse()

service := NewServer()

fs := http.FileServer(http.Dir("public"))
Expand All @@ -25,7 +32,7 @@ func main() {

wrappedServer := grpcweb.WrapServer(gRPCServer)

listener, err := net.Listen("tcp", "0.0.0.0:3000")
listener, err := net.Listen("tcp", *address+":"+strconv.Itoa(*port))
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -127,7 +134,7 @@ func main() {
)),
}

log.Println("listening on port 3000")
log.Printf("listening on port %v\n", *port)

server.Serve(listener)
}

0 comments on commit 5db4b97

Please sign in to comment.