Skip to content

Commit

Permalink
Set the default buildConcurrency to cpu numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Nov 11, 2023
1 parent 73a39cd commit 103e54a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions config.example.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// The port to listen server on for node service, default is 8088 (do not change if you don't know what you are doing).
"nsPort": 8088,

// The build max concurrency, default is `max(4, 2*NumCPU)`
// The build max concurrency, default is `runtime.NumCPU()`
"buildConcurrency": 0,

// The work directory for the server app, default is "~/.esmd".
Expand Down Expand Up @@ -80,7 +80,7 @@
"allowList": {
"packages": ["@some_scope/package_name"],
"scopes": [{
"name": "@your_scope",
"name": "@your_scope"
}]
}
}
14 changes: 5 additions & 9 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/ije/gox/utils"
)

const MinBuildConcurrency = 4

type Config struct {
Port uint16 `json:"port,omitempty"`
TlsPort uint16 `json:"tlsPort,omitempty"`
Expand Down Expand Up @@ -55,7 +53,7 @@ type AllowList struct {
}

type AllowScope struct {
Name string `json:"name"`
Name string `json:"name"`
}

// Load loads config from the given file. Panic if failed to load.
Expand Down Expand Up @@ -146,10 +144,7 @@ func fixConfig(c *Config) *Config {
}
}
if c.BuildConcurrency == 0 {
c.BuildConcurrency = uint16(2 * runtime.NumCPU())
}
if c.BuildConcurrency < MinBuildConcurrency {
c.BuildConcurrency = MinBuildConcurrency
c.BuildConcurrency = uint16(runtime.NumCPU())
}
if c.Cache == "" {
c.Cache = "memory:default"
Expand Down Expand Up @@ -223,7 +218,7 @@ func extractPackageName(packageName string) (fullNameWithoutVersion string, scop
// The `packages` list is the highest priority ban rule to match,
// so the `excludes` list in the `scopes` list won't take effect if the package is banned in `packages` list
func (banList *BanList) IsPackageBanned(fullName string) bool {
fullNameWithoutVersion, scope, nameWithoutVersionScope := extractPackageName(fullName)
fullNameWithoutVersion, scope, nameWithoutVersionScope := extractPackageName(fullName)

for _, p := range banList.Packages {
if fullNameWithoutVersion == p {
Expand All @@ -247,7 +242,8 @@ func (allowList *AllowList) IsPackageAllowed(fullName string) bool {
if len(allowList.Packages) == 0 && len(allowList.Scopes) == 0 {
return true
}
fullNameWithoutVersion, scope, _ := extractPackageName(fullName)

fullNameWithoutVersion, scope, _ := extractPackageName(fullName)

for _, p := range allowList.Packages {
if fullNameWithoutVersion == p {
Expand Down

0 comments on commit 103e54a

Please sign in to comment.