Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #40 from helsinki-systems/feat-no-access-log
Browse files Browse the repository at this point in the history
cmd/nix_casync/main.go: add flag to disable access log
  • Loading branch information
flokli authored Jan 20, 2022
2 parents 75dd480 + bccd749 commit 4eb4ff3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/nix_casync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var CLI struct {
ListenAddr string `name:"listen-addr" help:"The address this service listens on" type:"string" default:"[::]:9000"`
Priority int `name:"priority" help:"What priority to advertise in nix-cache-info. Defaults to 40." type:"int" default:40`
AvgChunkSize int `name:"avg-chunk-size" help:"The average chunking size to use when chunking NAR files, in bytes. Max is 4 times that, Min is a quarter of this value." type:"int" default:65536`
AccessLog bool `name:"access-log" help:"Enable access logging" type:"bool" default:true negatable:""`
} `cmd serve:"Serve a local nix cache."`
}

Expand Down Expand Up @@ -60,11 +61,14 @@ func main() {
log.Printf("Starting Server at %v", CLI.Serve.ListenAddr)
srv := &http.Server{
Addr: CLI.Serve.ListenAddr,
Handler: middleware.Logger(s.Handler),
Handler: s.Handler,
ReadTimeout: 50 * time.Second,
WriteTimeout: 100 * time.Second,
IdleTimeout: 150 * time.Second,
}
if CLI.Serve.AccessLog {
srv.Handler = middleware.Logger(s.Handler)
}
log.Fatal(srv.ListenAndServe())
default:
panic(ctx.Command())
Expand Down

0 comments on commit 4eb4ff3

Please sign in to comment.