Skip to content

Commit ee6be12

Browse files
authored
feat: initial tagged version (#2)
* feat(runtime): send stderr to lambda logs * ci: add semantic versioning
1 parent a77a781 commit ee6be12

3 files changed

Lines changed: 55 additions & 6 deletions

File tree

.github/workflows/main-release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
permissions:
8+
issues: write
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-module:
14+
name: Release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 'lts/*'
25+
- name: Install dependencies
26+
run: npm install
27+
- name: Release
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: npx semantic-release

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "lambda-shell-endpoint",
3+
"private": true,
4+
"devDependencies": {
5+
"@semantic-release/github": "^12.0.6",
6+
"semantic-release": "^25.0.3"
7+
},
8+
"release": {
9+
"branches": [
10+
"main"
11+
]
12+
},
13+
"plugins": [
14+
"@semantic-release/commit-analyzer",
15+
"@semantic-release/release-notes-generator",
16+
"@semantic-release/github"
17+
]
18+
}

runtime/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ func (c *runtimeAPIClient) getNextInvocation() (string, []byte, error) {
2424
return "", nil, err
2525
}
2626
defer conn.Close()
27-
27+
2828
fmt.Fprintf(conn, "GET /2018-06-01/runtime/invocation/next HTTP/1.1\r\nHost: %s\r\n\r\n", c.host)
29-
29+
3030
reader := bufio.NewReader(conn)
3131
var requestID string
3232
var contentLength int
33-
33+
3434
for {
3535
line, _ := reader.ReadString('\n')
3636
if strings.HasPrefix(line, "Lambda-Runtime-Aws-Request-Id:") {
@@ -43,7 +43,7 @@ func (c *runtimeAPIClient) getNextInvocation() (string, []byte, error) {
4343
break
4444
}
4545
}
46-
46+
4747
body := make([]byte, contentLength)
4848
reader.Read(body)
4949
return requestID, body, nil
@@ -55,7 +55,7 @@ func (c *runtimeAPIClient) sendResponse(requestID string, response []byte) error
5555
return err
5656
}
5757
defer conn.Close()
58-
58+
5959
fmt.Fprintf(conn, "POST /2018-06-01/runtime/invocation/%s/response HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s", requestID, c.host, len(response), response)
6060
return nil
6161
}
@@ -66,7 +66,7 @@ func (c *runtimeAPIClient) sendError(requestID, errorMsg string) error {
6666
return err
6767
}
6868
defer conn.Close()
69-
69+
7070
errorPayload := `{"errorMessage": "` + errorMsg + `", "errorType": "Runtime.HandlerError"}`
7171
fmt.Fprintf(conn, "POST /2018-06-01/runtime/invocation/%s/error HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s", requestID, c.host, len(errorPayload), errorPayload)
7272
return nil
@@ -75,6 +75,7 @@ func (c *runtimeAPIClient) sendError(requestID, errorMsg string) error {
7575
func executeShellHandler(handlerFile, handlerFunc string, eventData []byte) ([]byte, error) {
7676
cmd := exec.Command("bash", "-c", "source "+handlerFile+" && "+handlerFunc)
7777
cmd.Stdin = strings.NewReader(string(eventData))
78+
cmd.Stderr = os.Stderr
7879
return cmd.Output()
7980
}
8081

0 commit comments

Comments
 (0)