diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 415f1e94..a751319b 100755 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -632,6 +632,7 @@ class AppBase: # I wonder if this actually works url = "%s%s" % (self.base_url, stream_path) + self.logger.info(f"[DEBUG][%s] Sending result to %s" % (self.current_execution_id, url)) try: log_contents = "disabled: add env SHUFFLE_LOGS_DISABLED=true to Orborus to re-enable logs for apps. Can not be enabled natively in Cloud except in Hybrid mode." @@ -656,6 +657,13 @@ class AppBase: except Exception as e: pass + # Check if type of headers is right + if not isinstance(headers, dict): + headers = {} + + if not "User-Agent" in headers: + headers["User-Agent"] = "Shuffle App" + try: finished = False ret = {} @@ -684,23 +692,23 @@ class AppBase: headerauth = headers["Authorization"] try: - self.logger.info(f"[ERROR] Bad resp ({ret.status_code}) in send_result for url '{url}'. Execution ID: %d, Authorization: %d, Header Auth: %d" % (len(action_result["execution_id"]), len(action_result["authorization"]), len(headerauth))) except Exception as e: self.logger.info(f"[ERROR] Bad resp ({ret.status_code}) in send_result for url '{url}' (no detail)") - pass time.sleep(sleeptime) # Proxyerrror except requests.exceptions.ProxyError as e: + self.logger.info(f"[ERROR][{self.current_execution_id}] Proxy error in send_result for url '{url}': {e}") + self.proxy_config = {} continue except requests.exceptions.RequestException as e: - time.sleep(sleeptime) + self.logger.info(f"[ERROR][{self.current_execution_id}] Request error in send_result for url '{url}': {e}") # Check if we have a read timeout. If we do, exit as we most likely sent the result without getting a good result if "Read timed out" in str(e): @@ -713,24 +721,34 @@ class AppBase: finished = True break + time.sleep(sleeptime) + #time.sleep(5) continue except TimeoutError as e: + self.logger.info(f"[ERROR][{self.current_execution_id}] Timeout error in send_result for url '{url}': {e}") + time.sleep(sleeptime) #time.sleep(5) continue except requests.exceptions.ConnectionError as e: + self.logger.info(f"[ERROR][{self.current_execution_id}] Connection error in send_result for url '{url}': {e}") + time.sleep(sleeptime) #time.sleep(5) continue except http.client.RemoteDisconnected as e: + self.logger.info(f"[ERROR][{self.current_execution_id}] RemoteDisconnected error in send_result for url '{url}': {e}") + time.sleep(sleeptime) #time.sleep(5) continue except urllib3.exceptions.ProtocolError as e: + self.logger.info(f"[ERROR][{self.current_execution_id}] ProtocolError error in send_result for url '{url}': {e}") + time.sleep(0.1) #time.sleep(5) @@ -3668,7 +3686,7 @@ class AppBase: #self.logger.info() if not multiexecution: - self.logger.info("NOT MULTI EXEC") + #self.logger.info("NOT MULTI EXEC") # Runs a single iteration here new_params = self.validate_unique_fields(params) if isinstance(new_params, list) and len(new_params) == 1: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e9d6d683..32b494c6 100755 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -25,29 +25,34 @@ COPY ./*.json /usr/src/app/ RUN npm run build --loglevel verbose 2>&1 # Production environment -FROM nginx:1.21.5 +FROM nginx:1.26.0 RUN mkdir -p /usr/share/nginx/html/build RUN mkdir -p /usr/share/nginx/html/css RUN mkdir -p /usr/share/nginx/html/js RUN mkdir -p /usr/share/nginx/html/img -COPY --from=builder /usr/src/app/build /usr/share/nginx/html -#Localhost certificate challenge: Y#XwrJ#DoZGz2w6x +# Localhost certificate challenge: Y#XwrJ#DoZGz2w6x +# Cert challenge doesn't matter to be here or not, as ALL production setups should be using their own certificates + reverse proxy: https://shuffler.io/docs/configuration#using-the-nginx-reverse-proxy-for-tls/ssl +COPY --from=builder /usr/src/app/build /usr/share/nginx/html COPY --from=builder /usr/src/app/certs/fullchain.pem /etc/nginx/fullchain.cert.pem COPY --from=builder /usr/src/app/certs/privkey.pem /etc/nginx/privkey.pem # install CONFD -ENV CONFD_VERSION 0.16.0 RUN apt-get update && apt-get install -y curl && apt-get clean -RUN curl -sSL https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 -o /usr/local/bin/confd && \ - chmod +x /usr/local/bin/confd -COPY ./confd /etc/confd +COPY ./confd/templates/nginx.conf /etc/nginx/nginx.conf +## OLD CONFD THINGS (not compatible with arm) +#ENV CONFD_VERSION 0.16.0 +#RUN curl -sSL https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 -o /usr/local/bin/confd && \ +# chmod +x /usr/local/bin/confd +#COPY ./confd /etc/confd # rewrite command & entrypoint with ours -COPY ./entrypoint.sh / -ENTRYPOINT [ "/entrypoint.sh" ] +#COPY ./entrypoint.sh / +#ENTRYPOINT [ "/entrypoint.sh" ] + + CMD ["nginx", "-g", "daemon off;"] EXPOSE 80 diff --git a/frontend/entrypoint.sh b/frontend/entrypoint.sh index 09be2558..f5542b05 100755 --- a/frontend/entrypoint.sh +++ b/frontend/entrypoint.sh @@ -1,7 +1,8 @@ #!/bin/bash -# generate configs -/usr/local/bin/confd -backend="env" -confdir="/etc/confd" -onetime +# generate configs - is this necessary? +# Removing confd if possible +#/usr/local/bin/confd -backend="env" -confdir="/etc/confd" -onetime # run main command exec "$@"