Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ COPY *.go ./

RUN go build -o /someguy

EXPOSE 8080

CMD [ "/someguy", "start", "--port", "8080" ]
Comment on lines -13 to -15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ removed defaults from Dockerfile. Rainbow did not have them, Someguy also should not.

CMD [ "/someguy", "start" ]
8 changes: 4 additions & 4 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
`someguy` ships with some implicit defaults that can be adjusted via env variables below.

- [Configuration](#configuration)
- [`SOMEGUY_PORT`](#someguy_port)
- [`SOMEGUY_LISTEN_ADDRESS`](#someguy_listen_address)
- [`SOMEGUY_ACCELERATED_DHT`](#someguy_accelerated_dht)
- [`SOMEGUY_PROVIDER_ENDPOINTS`](#someguy_provider_endpoints)
- [`SOMEGUY_PEER_ENDPOINTS`](#someguy_peer_endpoints)
Expand All @@ -16,11 +16,11 @@

## Configuration

### `SOMEGUY_PORT`
### `SOMEGUY_LISTEN_ADDRESS`

The port to listen on to.
The address to listen on.

Default: `8080`
Default: `127.0.0.1:8190`

### `SOMEGUY_ACCELERATED_DHT`

Expand Down
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func main() {
{
Name: "start",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "port",
Value: 8080,
EnvVars: []string{"SOMEGUY_PORT"},
Usage: "port to serve requests on",
&cli.StringFlag{
Name: "listen-address",
Value: "127.0.0.1:8190",
EnvVars: []string{"SOMEGUY_LISTEN_ADDRESS"},
Usage: "listen address",
},
&cli.BoolFlag{
Name: "accelerated-dht",
Expand Down Expand Up @@ -54,7 +54,7 @@ func main() {
},
},
Action: func(ctx *cli.Context) error {
return start(ctx.Context, ctx.Int("port"), ctx.Bool("accelerated-dht"), ctx.StringSlice("provider-endpoints"), ctx.StringSlice("peer-endpoints"), ctx.StringSlice("ipns-endpoints"))
return start(ctx.Context, ctx.String("listen-address"), ctx.Bool("accelerated-dht"), ctx.StringSlice("provider-endpoints"), ctx.StringSlice("peer-endpoints"), ctx.StringSlice("ipns-endpoints"))
},
},
{
Expand Down
15 changes: 10 additions & 5 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"context"
"log"
"net"
"net/http"
"strconv"

"github.com/CAFxX/httpcompression"
"github.com/felixge/httpsnoop"
Expand Down Expand Up @@ -32,7 +32,7 @@ func withRequestLogger(next http.Handler) http.Handler {
})
}

func start(ctx context.Context, port int, runAcceleratedDHTClient bool, contentEndpoints, peerEndpoints, ipnsEndpoints []string) error {
func start(ctx context.Context, listenAddress string, runAcceleratedDHTClient bool, contentEndpoints, peerEndpoints, ipnsEndpoints []string) error {
h, err := newHost(runAcceleratedDHTClient)
if err != nil {
return err
Expand Down Expand Up @@ -68,8 +68,13 @@ func start(ctx context.Context, port int, runAcceleratedDHTClient bool, contentE
return err
}

log.Printf("Listening on http://0.0.0.0:%d", port)
log.Printf("Delegated Routing API on http://127.0.0.1:%d/routing/v1", port)
_, port, err := net.SplitHostPort(listenAddress)
if err != nil {
return err
}

log.Printf("Listening on %s", listenAddress)
log.Printf("Delegated Routing API on http://127.0.0.1:%s/routing/v1", port)

mdlw := middleware.New(middleware.Config{
Recorder: metrics.NewRecorder(metrics.Config{Prefix: "someguy"}),
Expand Down Expand Up @@ -103,7 +108,7 @@ func start(ctx context.Context, port int, runAcceleratedDHTClient bool, contentE

http.Handle("/debug/metrics/prometheus", promhttp.Handler())
http.Handle("/", handler)
server := &http.Server{Addr: ":" + strconv.Itoa(port), Handler: nil}
server := &http.Server{Addr: listenAddress, Handler: nil}
return server.ListenAndServe()
}

Expand Down