Skip to content

Compatibility w/ AWS Fargate #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b57d8f4
Merge pull request #53 from aws/develop
valerena Sep 29, 2021
49c35f6
v1.3 release
valerena Nov 15, 2021
43a7a09
Merge changes for v1.8 release
valerena Sep 22, 2022
5a79e1e
Merge changes for v1.9 release
valerena Nov 1, 2022
9de974f
Merge changes for v1.11 release
valerena May 3, 2023
23f8171
Merge changes for v1.12 release
valerena Jun 8, 2023
04389ef
fix cors error
w3ichen Jul 26, 2023
b77ed50
upload bin/
w3ichen Jul 26, 2023
09c6ee6
add AWS_LAMBDA_SERVER_MAX_INVOCATIONS
w3ichen Jul 29, 2023
e12199d
grace period before server shutdown
w3ichen Jul 30, 2023
1fb9aec
wait for request to finish before shutdown
w3ichen Aug 1, 2023
0bc0798
fixing done channel
w3ichen Aug 1, 2023
6463ccb
change shutdown
w3ichen Aug 2, 2023
21939ab
Added forward-response header
w3ichen Aug 2, 2023
eefe267
ADD API_ACCESS_KEY
w3ichen Aug 10, 2023
0850a09
Create lambda-entrypoint.sh (copied from docker image)
w3ichen Aug 12, 2023
d58347f
Update lambda-entrypoint.sh with api_access_key.env file
w3ichen Aug 12, 2023
f51d540
Update lambda-entrypoint.sh
w3ichen Aug 13, 2023
9968f96
Update lambda-entrypoint.sh
w3ichen Aug 13, 2023
9bf5ab5
rm api_access_key
w3ichen Aug 13, 2023
aad4d03
Update lambda-entrypoint.sh
w3ichen Sep 30, 2023
21fb963
Create lambda-entrypoint.original.sh
w3ichen Sep 30, 2023
b1f7acf
Run lambda-entrypoint.sh as user
w3ichen Sep 30, 2023
680dd42
Update lambda-entrypoint.sh
w3ichen Sep 30, 2023
8b28927
remove lambda-entrypoint
w3ichen Sep 30, 2023
7617a6b
fix seg fault error binaries
w3ichen Dec 19, 2024
a1f0f8c
fix seg fault error binaries
w3ichen Dec 19, 2024
84fbc7a
Update README.md
w3ichen Dec 19, 2024
d6d2060
new binaries with patches
w3ichen Dec 19, 2024
1b6af0a
re-upload binaries compiled for linux
w3ichen Dec 19, 2024
d907de5
re-upload binaries compiled for linux
w3ichen Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change shutdown
  • Loading branch information
w3ichen committed Aug 2, 2023
commit 6463ccb19750a2c3de8db82718da4d93f035a107
Binary file modified bin/aws-lambda-rie
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary built files

Binary file not shown.
Binary file modified bin/aws-lambda-rie-arm64
Binary file not shown.
Binary file modified bin/aws-lambda-rie-x86_64
Binary file not shown.
4 changes: 2 additions & 2 deletions cmd/aws-lambda-rie/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func printEndReports(invokeId string, initDuration string, memorySize string, in
invokeId, invokeDuration, math.Ceil(invokeDuration), memorySize, memorySize)
}

func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox, bs interop.Bootstrap, done chan<- struct{}) {
func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox, bs interop.Bootstrap, doneCallback func()) {
log.Debugf("invoke: -> %s %s %v", r.Method, r.URL, r.Header)
bodyBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
Expand Down Expand Up @@ -191,7 +191,7 @@ func InvokeHandler(w http.ResponseWriter, r *http.Request, sandbox Sandbox, bs i
}
w.Write(invokeResp.Body)

close(done) // Signal that the InvokeHandler has completed its execution
doneCallback() // Callback at end of InvokeHandler
}

func InitHandler(sandbox Sandbox, functionVersion string, timeout int64, bs interop.Bootstrap) (time.Time, time.Time) {
Expand Down
19 changes: 7 additions & 12 deletions cmd/aws-lambda-rie/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main

import (
"os"
"time"
"strconv"
"net/http"

Expand Down Expand Up @@ -35,24 +34,20 @@ func startHTTPServer(ipport string, sandbox *rapidcore.SandboxBuilder, bs intero

// Pass a channel
http.HandleFunc("/2015-03-31/functions/function/invocations", func(w http.ResponseWriter, r *http.Request) {
done := make(chan struct{}) // Channel to signal when the response has terminated

InvokeHandler(w, r, sandbox.LambdaInvokeAPI(), bs, done)

// Shutdown the server if we've reached the maximum number of invocations
maxInvocations--
if maxInvocations == 0 {
<-done // Wait until the response has terminated
close(shutdownChan)
}
InvokeHandler(w, r, sandbox.LambdaInvokeAPI(), bs, func(){
// Shutdown the server if the maximum number of invocations is reached
maxInvocations--
if maxInvocations == 0 {
close(shutdownChan)
}
Comment on lines +84 to +87
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decrement the maxInvocations, if ==0, then shut down the server

})
})


// go routine to handle server shutdown (main thread waits)
go func() {
<-shutdownChan
log.Printf("Maximum invocations (%s) reached. Shutting down the server.", maxInvocationsStr)
time.Sleep(60 * time.Second) // Grace period for client to receive the response
if err := srv.Shutdown(nil); err != nil {
log.Panic(err)
}
Expand Down