From a4856d96193a8e7fbf40320fee905af04c6b34c9 Mon Sep 17 00:00:00 2001 From: Christopher Hase Date: Tue, 25 Mar 2025 15:04:48 +0100 Subject: [PATCH] Logging --- Dockerfile | 9 +++++++++ broker.ts | 13 +++++++------ deployment.yaml | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 258f419..2db6980 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ # 1. Node.js Build-Stage FROM node:20.18.1 AS build +RUN echo "Stage 1 startet" + WORKDIR /app COPY package*.json ./ @@ -10,17 +12,24 @@ RUN npm install RUN npx tsc # TypeScript Code kompilieren # 2. Rust Build-Stage + +RUN echo "Stage 2 startet" + FROM rust:1.74.0 AS rust-build RUN cargo install iching # 3. Final Node.js Runtime-Stage FROM node:20.18.1 +RUN echo "Stage 3 startet" + WORKDIR /app # 4 Copy previous builds COPY --from=build /app . COPY --from=rust-build /usr/local/cargo/bin/iching /usr/local/bin/iching +RUN echo "Calling Broker" + CMD ["npx", "ts-node", "broker.ts"] #CMD ["npx", "ts-node", "mailsender.ts"] \ No newline at end of file diff --git a/broker.ts b/broker.ts index 253394e..8fb2a05 100644 --- a/broker.ts +++ b/broker.ts @@ -4,11 +4,10 @@ const nodemailer = require('nodemailer'); exec('iching divine', (error, stdout, stderr) => { - console.log(`Beginn`); - + console.log(`Begin`); if (error) { - console.error(`Fehler: ${error.message}`); + console.error(`Error: ${error.message}`); return; } @@ -19,6 +18,8 @@ exec('iching divine', (error, stdout, stderr) => { //console.log(`Ergebnis:\n${stdout}`); + console.log(`Send E-Mail`); + sendEmail(stdout); //TODO: param }); @@ -28,7 +29,7 @@ const transporter = nodemailer.createTransport({ host: "mailhog.mailhog.svc.cluster.local", // MailHog ClusterIP port: 1025, // Standard-MailHog SMTP-Port secure: false // MailHog benötigt keine Verschlüsselung -}); + }); // E-Mail senden async function sendEmail(content: string) { //TODO: param @@ -41,9 +42,9 @@ const transporter = nodemailer.createTransport({ html: "

${content}

" }); - console.log("E-Mail gesendet: ", info.messageId); + console.log("E-Mail sent: ", info.messageId); } catch (error) { - console.error("Fehler beim Senden der E-Mail:", error); + console.error("Error Sending E-Mail:", error); } } \ No newline at end of file diff --git a/deployment.yaml b/deployment.yaml index 9c09097..cbe3689 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -1,7 +1,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: iching-broker-0-0-2 + name: iching-broker-0-0-1 namespace: default spec: selector: