Skip to content

Commit

Permalink
add timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
wj00037 committed Oct 17, 2024
1 parent 5535ef3 commit 4898f48
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ module github.com/metalogical/BigFiles

go 1.21

toolchain go1.23.1
toolchain go1.21.4

require (
github.com/go-chi/chi v4.1.2+incompatible
github.com/minio/minio-go/v7 v7.0.77
sigs.k8s.io/yaml v1.4.0
)

require github.com/aws/aws-lambda-go v1.43.0 // indirect

require (
github.com/akrylysov/algnhsa v1.1.0
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
Expand All @@ -27,4 +24,5 @@ require (
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
github.com/akrylysov/algnhsa v1.1.0 h1:G0SoP16tMRyiism7VNc3JFA0wq/cVgEkp/ExMVnc6PQ=
github.com/akrylysov/algnhsa v1.1.0/go.mod h1:+bOweRs/WBu5awl+ifCoSYAuKVPAmoTk8XOMrZ1xwiw=
github.com/aws/aws-lambda-go v1.43.0 h1:Tdu7SnMB5bD+CbdnSq1Dg4sM68vEuGIDcQFZ+IjUfx0=
github.com/aws/aws-lambda-go v1.43.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
20 changes: 11 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"log"
"net/http"
"os"
"strings"
"time"

"github.com/akrylysov/algnhsa"
"github.com/metalogical/BigFiles/auth"
"github.com/metalogical/BigFiles/config"
"github.com/metalogical/BigFiles/server"
Expand Down Expand Up @@ -112,16 +111,19 @@ func main() {
IsAuthorized: auth.GiteeAuth(),
SecretAccessKey: cfg.AwsSecretAccessKey,
})
srv := &http.Server{
Addr: "0.0.0.0:5000",
Handler: s,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 30 * time.Second,
}
if err != nil {
log.Fatalln(err)
}

if strings.HasPrefix(os.Getenv("AWS_EXECUTION_ENV"), "AWS_Lambda_") {
algnhsa.ListenAndServe(s, nil)
} else {
log.Println("serving on http://0.0.0.0:5000 ...")
if err := http.ListenAndServe("0.0.0.0:5000", s); err != nil {
log.Fatalln(err)
}
log.Println("serving on http://0.0.0.0:5000 ...")
if err := srv.ListenAndServe(); err != nil {
log.Fatalln(err)
}
}

0 comments on commit 4898f48

Please sign in to comment.