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 *
1
2
.DS_Store
2
3
.vscode
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
- # set -u
3
+ set -uo pipefail
4
4
5
5
# Constants
6
6
RUNTIME_PATH=" 2018-06-01/runtime"
@@ -20,7 +20,7 @@ sendRuntimeError () {
20
20
ERROR_TYPE=$3
21
21
STACK_TRACE=$4
22
22
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
24
24
}
25
25
26
26
# Send successful response to Lambda API
@@ -42,17 +42,17 @@ source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh"
42
42
while true
43
43
do
44
44
HEADERS=" $( mktemp) "
45
+ RESPONSE=" $( mktemp) "
45
46
EVENT_DATA=$( curl -sS -LD " $HEADERS " -X GET " http://${AWS_LAMBDA_RUNTIME_API} /${RUNTIME_PATH} /invocation/next" )
46
47
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
50
49
EXIT_CODE=$?
51
50
if [[ $EXIT_CODE -eq " 0" ]]; then
52
- sendResponse $REQUEST_ID $LAMBDA_RETURN_VALUE
51
+ sendResponse " $REQUEST_ID " " $( cat $RESPONSE ) "
53
52
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 ) "
57
55
fi
56
+ rm -f $HEADERS
57
+ rm -f $RESPONSE
58
58
done
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