Skip to content

Commit

Permalink
Add JSON schema
Browse files Browse the repository at this point in the history
Fix bug with missing defaults for pool
Only enable SSL if both cert and key is provided, not just one of them
Fix wrong doc about unlimited MaxRequestSize (0 gets set to 1000 in default)
  • Loading branch information
nickdnk committed Oct 24, 2024
1 parent 55e549d commit 0966ede
Show file tree
Hide file tree
Showing 2 changed files with 473 additions and 15 deletions.
20 changes: 5 additions & 15 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package config

import (
"runtime"
"strings"
"time"

"github.com/roadrunner-server/http/v5/servers/fcgi"
"github.com/roadrunner-server/http/v5/servers/http3"
"github.com/roadrunner-server/http/v5/servers/https"
"strings"

"github.com/roadrunner-server/errors"
"github.com/roadrunner-server/pool/pool"
Expand All @@ -27,7 +24,7 @@ type Config struct {
Pool *pool.Config `mapstructure:"pool"`
// InternalErrorCode used to override default 500 (InternalServerError) http code
InternalErrorCode uint64 `mapstructure:"internal_error_code"`
// MaxRequestSize specified max size for payload body in megabytes, set 0 to unlimited.
// MaxRequestSize specified max size for payload body in megabytes. 0 = 1GB.
MaxRequestSize uint64 `mapstructure:"max_request_size"`
// SSLConfig defines https server options.
SSLConfig *https.SSL `mapstructure:"ssl"`
Expand Down Expand Up @@ -62,7 +59,7 @@ func (c *Config) EnableTLS() bool {
if c.SSLConfig.Acme != nil {
return true
}
return c.SSLConfig.Key != "" || c.SSLConfig.Cert != ""
return c.SSLConfig.Key != "" && c.SSLConfig.Cert != ""
}

// EnableFCGI is true when FastCGI server must be enabled.
Expand All @@ -76,16 +73,9 @@ func (c *Config) EnableFCGI() bool {
// InitDefaults must populate HTTP values using given HTTP source. Must return error if HTTP is not valid.
func (c *Config) InitDefaults() error {
if c.Pool == nil {
// default pool
c.Pool = &pool.Config{
Debug: false,
NumWorkers: uint64(runtime.NumCPU()), //nolint:gosec
MaxJobs: 0,
AllocateTimeout: time.Second * 60,
DestroyTimeout: time.Second * 60,
Supervisor: nil,
}
c.Pool = &pool.Config{}
}
c.Pool.InitDefaults()

if c.InternalErrorCode == 0 {
c.InternalErrorCode = 500
Expand Down
Loading

0 comments on commit 0966ede

Please sign in to comment.