When running with a custom `PORT` env variable, NGINX server will be listening on this port. In the backend's startup script, `run-java.sh`, we're checking for RTS being up or not, at `localhost`. So when the port is not 80, then this will never succeed, because it'll be looking for NGINX at the wrong port. Instead, the fix here will make the backend startup script hit RTS _directly_ on RTS server's own port, instead of going via NGINX. This means it's independent of both the `PORT` env variable and the NGINX server, and only dependent on RTS being up, which is really what we want here.
74 lines
2.1 KiB
Bash
Executable File
74 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
set -o nounset
|
|
set -o noglob
|
|
|
|
declare -a proxy_args
|
|
proxy_configured=0
|
|
|
|
match-proxy-url() {
|
|
# Examples:
|
|
# http://proxy.example.com:8080/
|
|
# http://user:pass@proxyhost:123
|
|
# http://proxyhost:123
|
|
[[ $1 =~ ^http://(([^@:]*):([^@]*)?@)?([^@:]*):([0-9]+)/?$ ]]
|
|
proxy_user="${BASH_REMATCH[2]-}"
|
|
proxy_pass="${BASH_REMATCH[3]-}"
|
|
proxy_host="${BASH_REMATCH[4]-}"
|
|
proxy_port="${BASH_REMATCH[5]-}"
|
|
[[ -n $proxy_host ]]
|
|
}
|
|
|
|
if match-proxy-url "${HTTP_PROXY-}"; then
|
|
proxy_args+=(-Dhttp.proxyHost="$proxy_host" -Dhttp.proxyPort="$proxy_port")
|
|
if [[ -n $proxy_user ]]; then
|
|
proxy_args+=(-Dhttp.proxyUser="$proxy_user")
|
|
fi
|
|
if [[ -n $proxy_pass ]]; then
|
|
proxy_args+=(-Dhttp.proxyPassword="$proxy_pass")
|
|
fi
|
|
proxy_configured=1
|
|
fi
|
|
|
|
if match-proxy-url "${HTTPS_PROXY-}"; then
|
|
proxy_args+=(-Dhttps.proxyHost="$proxy_host" -Dhttps.proxyPort="$proxy_port")
|
|
if [[ -n $proxy_user ]]; then
|
|
proxy_args+=(-Dhttps.proxyUser="$proxy_user")
|
|
fi
|
|
if [[ -n $proxy_pass ]]; then
|
|
proxy_args+=(-Dhttps.proxyPassword="$proxy_pass")
|
|
fi
|
|
proxy_configured=1
|
|
fi
|
|
|
|
if [[ -z "${NO_PROXY-}" ]]; then
|
|
# A default for this value is set in entrypoint.sh script.
|
|
# If this variable is not set, just set it to empty string.
|
|
NO_PROXY=""
|
|
fi
|
|
|
|
if [[ $proxy_configured == 1 ]]; then
|
|
proxy_args+=(-Djava.net.useSystemProxies=true -Dhttp.nonProxyHosts="${NO_PROXY//,/|}")
|
|
fi
|
|
|
|
# Wait until RTS started and listens on port 8091
|
|
while ! curl --fail --silent localhost:"${APPSMITH_RTS_PORT:-8091}"/rts-api/v1/health-check; do
|
|
echo 'Waiting for RTS to start ...'
|
|
sleep 1
|
|
done
|
|
echo 'RTS started.'
|
|
|
|
sh /opt/appsmith/run-starting-page-init.sh &
|
|
|
|
# Ref -Dlog4j2.formatMsgNoLookups=true https://spring.io/blog/2021/12/10/log4j2-vulnerability-and-spring-boot
|
|
exec java ${APPSMITH_JAVA_ARGS:-} ${APPSMITH_JAVA_HEAP_ARG:-} \
|
|
--add-opens java.base/java.time=ALL-UNNAMED \
|
|
-Dserver.port=8080 \
|
|
-XX:+ShowCodeDetailsInExceptionMessages \
|
|
-Djava.security.egd=file:/dev/./urandom \
|
|
-Dlog4j2.formatMsgNoLookups=true \
|
|
"${proxy_args[@]}" \
|
|
-jar server.jar
|