Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
sst.aws.Function: limit node build concurrency to 4 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Oct 11, 2024
1 parent 1bf0370 commit 695f091
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/runtime/node/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var forceExternal = []string{
}

func (r *Runtime) Build(ctx context.Context, input *runtime.BuildInput) (*runtime.BuildOutput, error) {
r.lock.Acquire(ctx, 1)
defer r.lock.Release(1)
var properties NodeProperties
json.Unmarshal(input.Properties, &properties)

Expand Down
9 changes: 9 additions & 0 deletions pkg/runtime/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import (
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"

"github.com/evanw/esbuild/pkg/api"
esbuild "github.com/evanw/esbuild/pkg/api"
"github.com/sst/ion/internal/util"
"github.com/sst/ion/pkg/flag"
"github.com/sst/ion/pkg/project/path"
"github.com/sst/ion/pkg/runtime"
"golang.org/x/sync/semaphore"
)

var loaderMap = map[string]api.Loader{
Expand Down Expand Up @@ -58,12 +61,18 @@ type Runtime struct {
cfgPath string
contexts map[string]esbuild.BuildContext
results map[string]esbuild.BuildResult
lock *semaphore.Weighted
}

func New() *Runtime {
weight := int64(4)
if flag.SST_BUILD_CONCURRENCY != "" {
weight, _ = strconv.ParseInt(flag.SST_BUILD_CONCURRENCY, 10, 64)
}
return &Runtime{
contexts: map[string]esbuild.BuildContext{},
results: map[string]esbuild.BuildResult{},
lock: semaphore.NewWeighted(weight),
}
}

Expand Down

0 comments on commit 695f091

Please sign in to comment.