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

Commit

Permalink
move worker to cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Feb 8, 2024
1 parent 6f56601 commit e71fb0c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/test/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { Resource } from "sst";
export async function handler() {
return {
statusCode: 200,
body: process.env.HELLO,
body: process.cwd(),
};
}
10 changes: 10 additions & 0 deletions pkg/platform/src/components/helpers/aws/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ export const bootstrap = {
}

const ssm = new SSMClient({
// credentials: {
// accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
// sessionToken: process.env.AWS_SESSION_TOKEN!,
// secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
// },
region,
});
const s3 = new S3Client({
region,
// credentials: {
// accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
// sessionToken: process.env.AWS_SESSION_TOKEN!,
// secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
// },
});
try {
const bucket = (async () => {
Expand Down
2 changes: 1 addition & 1 deletion pkg/project/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func GetSecrets(backend Backend, app, stage string) (map[string]string, error) {
}

func PutSecrets(backend Backend, app, stage string, data map[string]string) error {
slog.Info("putting secrets", "app", app, "stage", stage)
slog.Info("putting selinkscrets", "app", app, "stage", stage)
if data == nil || len(data) == 0 {
return nil
}
Expand Down
12 changes: 11 additions & 1 deletion pkg/runtime/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,18 @@ func (r *NodeRuntime) Build(ctx context.Context, input *BuildInput) (*BuildOutpu
}

func (r *NodeRuntime) Run(ctx context.Context, input *RunInput) (Worker, error) {
cmd := exec.CommandContext(ctx, "node", ".sst/platform/dist/nodejs-runtime/index.js", filepath.Join(input.Build.Out, input.Build.Handler), input.WorkerID)
cmd := exec.CommandContext(
ctx,
"node",
filepath.Join(
input.Project.PathPlatformDir(),
"/dist/nodejs-runtime/index.js",
),
filepath.Join(input.Build.Out, input.Build.Handler),
input.WorkerID,
)
cmd.Env = append(input.Env, "AWS_LAMBDA_RUNTIME_API=localhost:44149/lambda/"+input.WorkerID)
cmd.Dir = input.Build.Out
cmd.Start()
return &NodeWorker{
cmd,
Expand Down
1 change: 1 addition & 0 deletions pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type BuildOutput struct {
}

type RunInput struct {
Project *project.Project
FunctionID string
WorkerID string
Runtime string
Expand Down
1 change: 1 addition & 0 deletions pkg/server/dev/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func Start(
builds[functionID] = build
}
worker, _ := runtime.Run(ctx, &runtime.RunInput{
Project: p,
WorkerID: workerID,
Runtime: warp.Runtime,
FunctionID: functionID,
Expand Down

0 comments on commit e71fb0c

Please sign in to comment.