Skip to content

Commit

Permalink
Merge branch 'release' into fix/non-super-user-alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
dipyamanbiswas07 committed Jun 6, 2023
2 parents 3ab07eb + 2c9fc11 commit adce6fe
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 118 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \
supervisor curl cron certbot nginx gnupg wget netcat openssh-client \
software-properties-common gettext \
python3-pip python-setuptools git ca-certificates-java \
python3-pip python3-requests python-setuptools git ca-certificates-java \
&& wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add - \
&& echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list \
&& apt-get update && apt-get install --no-install-recommends --yes temurin-17-jdk \
Expand Down
14 changes: 0 additions & 14 deletions app/client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,6 @@ eslintConfig.overrides = [
getRestrictedSyntaxOverrideForCodeEditor(eslintConfig),
},
},
{
files: ["**/*.test.js", "*.test.ts", "*.test.tsx"],
rules: {
"no-restricted-syntax": [
"error",
{
selector:
'CallExpression[callee.object.name="it"][callee.property.name="only"], CallExpression[callee.object.name="describe"][callee.property.name="only"]',
message:
"Reason: Dangling *.only tests skip other tests in the file and reduce test coverage.",
},
],
},
},
];

function getRestrictedImportsOverrideForCodeEditor(eslintConfig) {
Expand Down
16 changes: 1 addition & 15 deletions app/client/cypress/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,5 @@
"@typescript-eslint/no-non-null-assertion": "error",
"cypress/unsafe-to-chain-command": "off",
"@typescript-eslint/adjacent-overload-signatures": "off"
},
"overrides": [
{
"files": ["**/*[sS]pec.js", "**/*[sS]pec.ts"],
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.object.name=\"it\"][callee.property.name=\"only\"], CallExpression[callee.object.name=\"describe\"][callee.property.name=\"only\"]",
"message": "Reason: Dangling *.only tests skip other tests in the file and reduce test coverage."
}
]
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
public class RedirectHelper {

public static final String DEFAULT_REDIRECT_URL = "/applications";
public static final String ERROR = "error";
public static final String CHARACTER_QUESTION_MARK = "?";
public static final String CHARACTER_EQUALS = "=";
public static final String SIGNUP_SUCCESS_URL = "/signup-success";
public static final String APPLICATION_PAGE_URL = "/applications/%s/pages/%s/edit";
private static final String REDIRECT_URL_HEADER = "X-Redirect-Url";
Expand Down Expand Up @@ -235,4 +238,30 @@ public String buildSignupSuccessUrl(String redirectUrl, boolean enableFirstTimeU
}
return url;
}

/**
* To build failure URL
* @param redirectPrefix Redirect URL prefix
* @param failureMessage Failure message to be added to redirect URL
* @return Redirect URL
*/
private String buildFailureUrl(String redirectPrefix, String failureMessage) {
String url = redirectPrefix + CHARACTER_QUESTION_MARK + ERROR + CHARACTER_EQUALS + URLEncoder.encode(failureMessage, StandardCharsets.UTF_8);

return url;
}

/**
* To redirect in error cases
* @param webFilterExchange WebFilterExchange
* @param redirectPrefix Redirect URL prefix
* @param failureMessage Failure message to be added to redirect URL
* @return Mono of void
*/
public Mono<Void> handleErrorRedirect(WebFilterExchange webFilterExchange, String redirectPrefix, String failureMessage) {
ServerWebExchange exchange = webFilterExchange.getExchange();
URI redirectURI = URI.create(buildFailureUrl(redirectPrefix, failureMessage));

return redirectStrategy.sendRedirect(exchange, redirectURI);
}
}
3 changes: 0 additions & 3 deletions deploy/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ configure_supervisord() {
fi

cp -f "$SUPERVISORD_CONF_PATH/application_process/"*.conf /etc/supervisor/conf.d

# Copy Supervisor Listiner confs to conf.d
cp -f "$SUPERVISORD_CONF_PATH/event_listeners/"*.conf /etc/supervisor/conf.d

# Disable services based on configuration
if [[ -z "${DYNO}" ]]; then
Expand Down
1 change: 1 addition & 0 deletions deploy/docker/scripts/run-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ while ! curl --fail --silent localhost/rts-api/v1/health-check; do
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:-} \
Expand Down
4 changes: 4 additions & 0 deletions deploy/docker/scripts/run-starting-page-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

python3 /opt/appsmith/starting-page-init.py
rm -f /opt/appsmith/editor/loading.html
81 changes: 81 additions & 0 deletions deploy/docker/scripts/starting-page-init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

import os
import sys
import time
import shutil
import subprocess
import logging
import traceback
import atexit


LOADING_TEMPLATE_PAGE = r'/opt/appsmith/templates/appsmith_starting.html'
LOADING_PAGE_EDITOR = r'/opt/appsmith/editor/loading.html'
BACKEND_HEALTH_ENDPOINT = "http://localhost:8080/api/v1/health"
LOG_FILE = r'/appsmith-stacks/logs/backend/starting_page_init.log'
LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'

logging.basicConfig(filename = LOG_FILE, level = logging.NOTSET, format = LOG_FORMAT)

try:
import requests
except ModuleNotFoundError as e:
logging.error("Module Not Found: " , e)


def get_backend_status():
try:
return subprocess.getoutput("supervisorctl status backend").split()[1]
except subprocess.CalledProcessError as e:
logging.error("Subprocess Error ", e)
except ValueError as e:
logging.error("Value Error ", e)

def check_health_endpoint(url,sleep_sec = 3,timeout_sec = 180):
for _ in range(timeout_sec//sleep_sec):
try:
if requests.get(url).ok:
logging.info('Backend health check successful.')
break
except ImportError as e:
logging.error("Import Error: ", e)
sys.exit(1)
except requests.RequestException:
pass # retry after sleep_sec
finally:
time.sleep(sleep_sec)
if get_backend_status() in ('FATAL' , 'BACKOFF'):
break
else:
logging.error('Timeout Error: Backend health check timeout.')

def remove_loading_page():
retries = 3
for _ in range(retries):
try:
if os.path.exists(LOADING_PAGE_EDITOR):
os.remove(LOADING_PAGE_EDITOR)
break
except OSError as e:
logging.error("Failed to remove loading page ", e)
time.sleep(1)
else:
logging.error("Loading page removal failed after %i retries. Trying again one final time.", retries)
logging.info(subprocess.getoutput("rm -fv " + LOADING_PAGE_EDITOR))


def add_loading_page():
shutil.copyfile(LOADING_TEMPLATE_PAGE, LOADING_PAGE_EDITOR)

@atexit.register
def failsafe():
remove_loading_page()

def main():
add_loading_page()
check_health_endpoint(BACKEND_HEALTH_ENDPOINT)
remove_loading_page()

if __name__ == '__main__':
main()

80 changes: 0 additions & 80 deletions deploy/docker/scripts/supervisor_event_listener.py

This file was deleted.

This file was deleted.

0 comments on commit adce6fe

Please sign in to comment.