mirror of https://github.com/caddyserver/caddy.git
fileserver: Add a few more debug lines (#4063)
This commit is contained in:
parent
a48c6205b7
commit
0018b9be0d
|
@ -295,8 +295,10 @@ func (fsrv *FileServer) openFile(filename string, w http.ResponseWriter) (*os.Fi
|
|||
if err != nil {
|
||||
err = mapDirOpenError(err, filename)
|
||||
if os.IsNotExist(err) {
|
||||
fsrv.logger.Debug("file not found", zap.String("filename", filename), zap.Error(err))
|
||||
return nil, caddyhttp.Error(http.StatusNotFound, err)
|
||||
} else if os.IsPermission(err) {
|
||||
fsrv.logger.Debug("permission denied", zap.String("filename", filename), zap.Error(err))
|
||||
return nil, caddyhttp.Error(http.StatusForbidden, err)
|
||||
}
|
||||
// maybe the server is under load and ran out of file descriptors?
|
||||
|
@ -304,6 +306,7 @@ func (fsrv *FileServer) openFile(filename string, w http.ResponseWriter) (*os.Fi
|
|||
//nolint:gosec
|
||||
backoff := weakrand.Intn(maxBackoff-minBackoff) + minBackoff
|
||||
w.Header().Set("Retry-After", strconv.Itoa(backoff))
|
||||
fsrv.logger.Debug("retry after backoff", zap.String("filename", filename), zap.Int("backoff", backoff), zap.Error(err))
|
||||
return nil, caddyhttp.Error(http.StatusServiceUnavailable, err)
|
||||
}
|
||||
return file, nil
|
||||
|
|
Loading…
Reference in New Issue