2022-03-17 13:10:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2022-06-01 05:44:27 +00:00
|
|
|
set -o errexit
|
|
|
|
|
set -o pipefail
|
|
|
|
|
set -o nounset
|
2022-06-15 08:31:46 +00:00
|
|
|
set -o noglob
|
2022-06-01 05:44:27 +00:00
|
|
|
|
2023-10-06 14:08:19 +00:00
|
|
|
declare -a extra_args
|
2022-06-15 08:31:46 +00:00
|
|
|
proxy_configured=0
|
2022-06-01 05:44:27 +00:00
|
|
|
|
2023-02-24 09:23:08 +00:00
|
|
|
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
|
2023-10-06 14:08:19 +00:00
|
|
|
extra_args+=(-Dhttp.proxyHost="$proxy_host" -Dhttp.proxyPort="$proxy_port")
|
2023-02-24 09:23:08 +00:00
|
|
|
if [[ -n $proxy_user ]]; then
|
2023-10-06 14:08:19 +00:00
|
|
|
extra_args+=(-Dhttp.proxyUser="$proxy_user")
|
2023-02-24 09:23:08 +00:00
|
|
|
fi
|
|
|
|
|
if [[ -n $proxy_pass ]]; then
|
2023-10-06 14:08:19 +00:00
|
|
|
extra_args+=(-Dhttp.proxyPassword="$proxy_pass")
|
2023-02-24 09:23:08 +00:00
|
|
|
fi
|
2022-06-15 08:31:46 +00:00
|
|
|
proxy_configured=1
|
2022-06-01 05:44:27 +00:00
|
|
|
fi
|
|
|
|
|
|
2023-02-24 09:23:08 +00:00
|
|
|
if match-proxy-url "${HTTPS_PROXY-}"; then
|
2023-10-06 14:08:19 +00:00
|
|
|
extra_args+=(-Dhttps.proxyHost="$proxy_host" -Dhttps.proxyPort="$proxy_port")
|
2023-02-24 09:23:08 +00:00
|
|
|
if [[ -n $proxy_user ]]; then
|
2023-10-06 14:08:19 +00:00
|
|
|
extra_args+=(-Dhttps.proxyUser="$proxy_user")
|
2023-02-24 09:23:08 +00:00
|
|
|
fi
|
|
|
|
|
if [[ -n $proxy_pass ]]; then
|
2023-10-06 14:08:19 +00:00
|
|
|
extra_args+=(-Dhttps.proxyPassword="$proxy_pass")
|
2023-02-24 09:23:08 +00:00
|
|
|
fi
|
2022-06-15 08:31:46 +00:00
|
|
|
proxy_configured=1
|
2022-06-01 05:44:27 +00:00
|
|
|
fi
|
|
|
|
|
|
2022-07-25 02:12:48 +00:00
|
|
|
if [[ -z "${NO_PROXY-}" ]]; then
|
2022-06-01 05:44:27 +00:00
|
|
|
# A default for this value is set in entrypoint.sh script.
|
2022-07-25 02:12:48 +00:00
|
|
|
# If this variable is not set, just set it to empty string.
|
2022-06-01 05:44:27 +00:00
|
|
|
NO_PROXY=""
|
|
|
|
|
fi
|
|
|
|
|
|
2022-06-15 08:31:46 +00:00
|
|
|
if [[ $proxy_configured == 1 ]]; then
|
2023-10-06 14:08:19 +00:00
|
|
|
extra_args+=(-Djava.net.useSystemProxies=true -Dhttp.nonProxyHosts="${NO_PROXY//,/|}")
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ -f "$TMP/java-cacerts-opts" ]]; then
|
|
|
|
|
extra_args+=("@$TMP/java-cacerts-opts")
|
2022-06-15 08:31:46 +00:00
|
|
|
fi
|
|
|
|
|
|
2023-01-02 09:55:23 +00:00
|
|
|
# Wait until RTS started and listens on port 8091
|
fix: Fix backend failing to start when running with a custom PORT (#27461)
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.
2023-09-20 04:57:54 +00:00
|
|
|
while ! curl --fail --silent localhost:"${APPSMITH_RTS_PORT:-8091}"/rts-api/v1/health-check; do
|
2023-01-02 09:55:23 +00:00
|
|
|
echo 'Waiting for RTS to start ...'
|
|
|
|
|
sleep 1
|
|
|
|
|
done
|
|
|
|
|
echo 'RTS started.'
|
|
|
|
|
|
2023-06-06 13:02:40 +00:00
|
|
|
sh /opt/appsmith/run-starting-page-init.sh &
|
2023-01-02 09:55:23 +00:00
|
|
|
|
2022-03-17 13:10:51 +00:00
|
|
|
# Ref -Dlog4j2.formatMsgNoLookups=true https://spring.io/blog/2021/12/10/log4j2-vulnerability-and-spring-boot
|
2022-06-01 05:44:27 +00:00
|
|
|
exec java ${APPSMITH_JAVA_ARGS:-} ${APPSMITH_JAVA_HEAP_ARG:-} \
|
2023-01-02 12:40:59 +00:00
|
|
|
--add-opens java.base/java.time=ALL-UNNAMED \
|
2023-12-26 04:34:09 +00:00
|
|
|
--add-opens java.base/java.nio=ALL-UNNAMED \
|
2022-06-01 05:44:27 +00:00
|
|
|
-Dserver.port=8080 \
|
2023-08-30 11:22:48 +00:00
|
|
|
-XX:+ShowCodeDetailsInExceptionMessages \
|
2022-06-01 05:44:27 +00:00
|
|
|
-Djava.security.egd=file:/dev/./urandom \
|
|
|
|
|
-Dlog4j2.formatMsgNoLookups=true \
|
2023-10-06 14:08:19 +00:00
|
|
|
"${extra_args[@]}" \
|
2022-06-01 05:44:27 +00:00
|
|
|
-jar server.jar
|