diff --git a/backend/broker.ts b/backend/broker.ts index 5cbee8d..fc012a3 100644 --- a/backend/broker.ts +++ b/backend/broker.ts @@ -79,7 +79,7 @@ async function sendEmail(content: string) { } catch (error) { console.error("Error Sending E-Mail:", error + "\n\n"); - console.log("Failed to send horoscope: \n", content + "\n"); + console.log("Failed to send this horoscope: \n", content + "\n"); } } diff --git a/deployment.yaml b/deployment.yaml index e75a70c..6e77607 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -1,3 +1,11 @@ +#env: +# - name: DEPLOY_MODE +# value: "kubernetes" +# - name: BACKEND_PORT +# value: "8090" + +#--- + # --- DEPLOYMENT -------------------------------------------- apiVersion: apps/v1 diff --git a/frontend/deploy.js b/frontend/deploy.js new file mode 100644 index 0000000..12e8f02 --- /dev/null +++ b/frontend/deploy.js @@ -0,0 +1 @@ +window.DEPLOY_MODE = "k8s" \ No newline at end of file diff --git a/frontend/event.ts b/frontend/event.ts index 3430561..1735143 100644 --- a/frontend/event.ts +++ b/frontend/event.ts @@ -1,7 +1,16 @@ function handleClick(): void { console.log("Der Button wurde geklickt!"); - fetch("/iching/api/command", { method: "POST" }) + const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' }).DEPLOY_MODE ?? 'k8s'; + + const endpoint = + deployMode === 'docker' + ? 'http://localhost:8090/iching/api/command' + : '/iching/api/command'; + + console.log(`DEPLOY_MODE=${deployMode}, sende POST an: ${endpoint}`); + + fetch(endpoint, { method: 'POST' }) .then(res => res.text()) .then(text => console.log("HTTP-Server says:", text)) .catch(error => console.error("HTTP-Server - Error:", error)); diff --git a/frontend/index.html b/frontend/index.html index 373974f..9c6984a 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -60,6 +60,8 @@ + + \ No newline at end of file diff --git a/start.sh b/start.sh index a48ebb0..1efc7c5 100755 --- a/start.sh +++ b/start.sh @@ -1,3 +1,13 @@ +#!/bin/bash + +# Setze Standard-Wert auf "k8s" wenn DEPLOY_MODE nicht gesetzt ist +DEPLOY_MODE=${DEPLOY_MODE:-k8s} + +echo "DEPLOY_MODE ist: $DEPLOY_MODE" + +# Injektiere ins Frontend +echo "window.DEPLOY_MODE = \"$DEPLOY_MODE\";" > dist/frontend/deploy.js + # start backend in the background node dist/backend/server.js &