generated from lambda-feedback/evaluation-function-boilerplate-wolfram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·40 lines (31 loc) · 1.01 KB
/
entrypoint.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
# set -e
# Prevent errors in a pipeline from being masked.
# set -o pipefail
# Start "wstpserver" in the background if `WSTP_SERVER` environment variable is set to `true`.
# The output of `wstpserver` will be redirected to stdout / stderr.
if [ "$WSTP_SERVER" = "true" ]; then
wstpserver &
fi
MAX_TRIES=20
TRY_COUNT=0
# Wait for the WSTP server to start by trying to establish a tcp connection to it.
while true; do
((TRY_COUNT++))
if ( ( echo > /dev/tcp/localhost/31415 ) &>/dev/null ); then
break
fi
if [[ "$TRY_COUNT" -ge "$MAX_TRIES" ]]; then
echo "Failed to reach wstpserver on port 31415 after $MAX_TRIES attempts."
exit 1
fi
echo "Waiting for the WSTP server to start ($TRY_COUNT/$MAX_TRIES)..."
sleep 1
done
# start the aws lambda RIE if AWS_LAMBDA_RIE is set, and AWS_LAMBDA_RUNTIME_API is not
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ] && [ -n "${AWS_LAMBDA_RIE}" ]; then
exec aws-lambda-rie "$@"
else
exec "$@"
fi