+ Please wait +
+Appsmith is initializing. This might take a few minutes.
+ +diff --git a/Dockerfile b/Dockerfile index 998d7afc13..acd38db0d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,6 +71,8 @@ COPY ./deploy/docker/templates/nginx/* \ ./deploy/docker/templates/docker.env.sh \ ./deploy/docker/templates/mockdb_postgres.sql \ ./deploy/docker/templates/users_postgres.sql \ + ./deploy/docker/templates/appsmith_starting.html \ + ./deploy/docker/templates/appsmith_initializing.html \ templates/ # Add bootstrapfile diff --git a/deploy/docker/entrypoint.sh b/deploy/docker/entrypoint.sh index defcc43015..b5f768b668 100755 --- a/deploy/docker/entrypoint.sh +++ b/deploy/docker/entrypoint.sh @@ -271,6 +271,9 @@ 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 @@ -377,7 +380,20 @@ runEmbeddedPostgres=1 init_postgres || runEmbeddedPostgres=0 } +init_loading_pages(){ + local starting_page="/opt/appsmith/templates/appsmith_starting.html" + local initializing_page="/opt/appsmith/templates/appsmith_initializing.html" + local editor_load_page="/opt/appsmith/editor/loading.html" + # Update default nginx page for initializing page + cp "$initializing_page" /var/www/html/index.nginx-debian.html + # Start nginx page to display the Appsmith is Initializing page + nginx + # Update editor nginx page for starting page + cp "$starting_page" "$editor_load_page" +} + # Main Section +init_loading_pages init_env_file setup_proxy_variables unset_unused_variables @@ -413,7 +429,10 @@ fi mkdir -p /appsmith-stacks/data/{backup,restore} # Create sub-directory to store services log in the container mounting folder -mkdir -p /appsmith-stacks/logs/{backend,cron,editor,rts,mongodb,redis,postgres} +mkdir -p /appsmith-stacks/logs/{backend,cron,editor,rts,mongodb,redis,postgres,appsmithctl} + +# Stop nginx gracefully +nginx -s quit # Handle CMD command exec "$@" diff --git a/deploy/docker/scripts/supervisor_event_listener.py b/deploy/docker/scripts/supervisor_event_listener.py new file mode 100644 index 0000000000..5b659dddc1 --- /dev/null +++ b/deploy/docker/scripts/supervisor_event_listener.py @@ -0,0 +1,74 @@ +import os +import requests +import sys +import shutil +import time + +LOADING_TEMPLATE_PAGE = r'/opt/appsmith/templates/appsmith_starting.html' +LOADING_PAGE_EDITOR = r'/opt/appsmith/editor/loading.html' +BACKEND_HEALTH_ENDPOINT = "http://localhost/api/v1/health" + +def write_stdout(s): + # only eventlistener protocol messages may be sent to stdout + sys.stdout.write(s) + sys.stdout.flush() + +def write_stderr(s): + sys.stderr.write(s) + sys.stderr.flush() + +def wait_until_backend_healthy(): + sleep_sec = 3 + timeout_sec = 120 + for _ in range(timeout_sec//sleep_sec): + if requests.get(BACKEND_HEALTH_ENDPOINT).ok: + write_stderr('\nBackend is healthy\n') + break + time.sleep(sleep_sec) + + else: + write_stderr('\nBackend health check timed out\n') + + remove_loading_page() + +def remove_loading_page(): + if os.path.exists(LOADING_PAGE_EDITOR): + os.remove(LOADING_PAGE_EDITOR) + +def main(): + while True: + # transition from ACKNOWLEDGED to READY + write_stdout('READY\n') + + # read header line and print it to stderr + line = sys.stdin.readline() + write_stderr(line) + + # read event payload and print it to stderr + headers = dict(x.split(':', 1) for x in line.split()) + data = sys.stdin.read(int(headers['len'])) + + if 'PROCESS_STATE_STARTING' in line: + data_params = dict([ x.split(':') for x in data.split()]) + if data_params['groupname'] == 'backend': + write_stderr('\nBackend State: STARTING\n') + shutil.copyfile(LOADING_TEMPLATE_PAGE, LOADING_PAGE_EDITOR) + + elif 'PROCESS_STATE_RUNNING' in line: + data_params = dict([ x.split(':') for x in data.split()]) + if data_params['groupname'] == 'backend': + write_stderr('\nBackend State: RUNNING\n') + wait_until_backend_healthy() + write_stderr(data) + + elif 'PROCESS_STATE_FATAL' in line: + data_params = dict([ x.split(':') for x in data.split()]) + if data_params['groupname'] == 'backend': + write_stderr('\nBackend State: FATAL\n') + remove_loading_page() + + # transition from READY to ACKNOWLEDGED + write_stdout('RESULT 2\nOK') + +if __name__ == '__main__': + main() diff --git a/deploy/docker/templates/appsmith_initializing.html b/deploy/docker/templates/appsmith_initializing.html new file mode 100644 index 0000000000..fba1f0dab2 --- /dev/null +++ b/deploy/docker/templates/appsmith_initializing.html @@ -0,0 +1,87 @@ + + +
+ + + ++ Please wait +
+Appsmith is initializing. This might take a few minutes.
+ ++ Appsmith is starting. +
+Please wait until Appsmith is ready. This process usually takes a minute.
+ +