File tree Expand file tree Collapse file tree 4 files changed +29
-20
lines changed
Expand file tree Collapse file tree 4 files changed +29
-20
lines changed Original file line number Diff line number Diff line change 1+ test *
12.DS_Store
23.vscode
Original file line number Diff line number Diff line change 11#! /bin/sh
22
3- # set -u
3+ set -uo pipefail
44
55# Constants
66RUNTIME_PATH=" 2018-06-01/runtime"
@@ -20,7 +20,7 @@ sendRuntimeError () {
2020 ERROR_TYPE=$3
2121 STACK_TRACE=$4
2222 ERROR=" {\" errorMessage\" : \" $ERROR_MESSAGE \" , \" errorType\" : \" $ERROR_TYPE \" , \" stackTrace\" : \" $STACK_TRACE \" }"
23- curl -sS -X POST -d " $ERROR " " http://${AWS_LAMBDA_RUNTIME_API} /${RUNTIME_PATH} /invocation/${REQUEST_ID} /error" > /dev/null
23+ curl -sS -X POST -d " $ERROR " " http://${AWS_LAMBDA_RUNTIME_API} /${RUNTIME_PATH} /invocation/${REQUEST_ID} /error" > /dev/null
2424}
2525
2626# Send successful response to Lambda API
@@ -42,17 +42,17 @@ source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh"
4242while true
4343do
4444 HEADERS=" $( mktemp) "
45+ RESPONSE=" $( mktemp) "
4546 EVENT_DATA=$( curl -sS -LD " $HEADERS " -X GET " http://${AWS_LAMBDA_RUNTIME_API} /${RUNTIME_PATH} /invocation/next" )
4647 REQUEST_ID=$( grep -Fi Lambda-Runtime-Aws-Request-Id " $HEADERS " | tr -d ' [:space:]' | cut -d: -f2)
47- RESPONSE=$( $( echo " $_HANDLER " | cut -d. -f2) " $EVENT_DATA " 2>&1 > /dev/null)
48- # Goal here is to only capture STDERR to the $RESPONSE variable and allow STDOUT to be logged like normal.
49- # Then for successful response messages we set them to a global variable $LAMBDA_RETURN_VALUE
48+ $( echo " $_HANDLER " | cut -d. -f2) " $EVENT_DATA " >&1 2> $RESPONSE | cat
5049 EXIT_CODE=$?
5150 if [[ $EXIT_CODE -eq " 0" ]]; then
52- sendResponse $REQUEST_ID $LAMBDA_RETURN_VALUE
51+ sendResponse " $REQUEST_ID " " $( cat $RESPONSE ) "
5352 else
54- echo " failure"
55- echo $RESPONSE
56- sendRuntimeError $REQUEST_ID " Exited with code $EXIT_CODE " " RuntimeErrorException" " $RESPONSE "
53+ cat $RESPONSE
54+ sendRuntimeError " $REQUEST_ID " " Exited with code $EXIT_CODE " " RuntimeErrorException" " $( cat $RESPONSE ) "
5755 fi
56+ rm -f $HEADERS
57+ rm -f $RESPONSE
5858done
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ function handler () {
4+ set -e
5+ EVENT_DATA=$1
6+ echo " this is my function"
7+ echo " this is my function"
8+ for i in ` seq 1 25` ;
9+ do
10+ echo $i
11+ done
12+ lsssss
13+ echo $?
14+ echo " after....."
15+ echo " TESTING" > /tmp/testing.out
16+ echo $?
17+ echo $EVENT_DATA >&2
18+
19+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments