Skip to content

Commit

Permalink
Improve listen address output
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Sep 16, 2023
1 parent db1c052 commit 934303e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
envPrefix = "GNO_FAUCET"
)

var (
const (
defaultGasFee = "1000000ugnot"
defaultGasWanted = "100000"
defaultRemote = "http://127.0.0.1:26657"
Expand Down
13 changes: 10 additions & 3 deletions faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net"
"net/http"
"time"

Expand Down Expand Up @@ -112,15 +113,21 @@ func (f *Faucet) Serve(ctx context.Context) error {
group, gCtx := errgroup.WithContext(ctx)

group.Go(func() error {
defer f.logger.Info("faucet shut down")

ln, err := net.Listen("tcp", faucet.Addr)
if err != nil {
return err
}

f.logger.Info(
fmt.Sprintf(
"faucet started at %s",
f.config.ListenAddress,
ln.Addr().String(),
),
)
defer f.logger.Info("faucet shut down")

if err := faucet.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
if err := faucet.Serve(ln); err != nil && !errors.Is(err, http.ErrServerClosed) {
return err
}

Expand Down

0 comments on commit 934303e

Please sign in to comment.