Skip to content

Commit

Permalink
chore:add host connection string (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
nully0x authored Dec 10, 2024
1 parent e30bb68 commit 342d967
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function getLanguageConfig(language: string): LanguageConfig {

export const config = {
port: process.env.PORT || 3001,
host: process.env.HOST || "0.0.0.0",
baseUrl: process.env.BASE_URL || "http://192.168.49.2:30025/api",
};

Expand Down
14 changes: 10 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import express from "express";
import express, { Request, Response } from "express";
import { runTestProcess } from "./utils/runner";
import { TestRunRequest } from "./models/types";
import {
Expand All @@ -14,11 +14,17 @@ import { establishSSEConnection } from "./controllers/sseController";
const app = express();
app.use(express.json());

const PORT = config.port;
const PORT = config.port as number;
const HOST = config.host;

// SSE endpoint
app.get("/logs/:commitSha", establishSSEConnection);

//health check
app.get("/health", (_req: Request, res: Response) => {
res.send("OK");
});

async function startConsumer() {
const channel = getChannel();
await channel.consume(rabbitMQConfig.queueTestRunner, async (msg) => {
Expand Down Expand Up @@ -46,8 +52,8 @@ async function startServer() {
await setupRabbitMQ();
await startConsumer();

app.listen(PORT, () => {
logger.info(`Test runner service listening on port ${PORT}`);
app.listen(PORT, HOST, () => {
logger.info(`Test runner service listening at http://${HOST}:${PORT}`);
});
} catch (error) {
logger.error("Failed to start server", { error });
Expand Down

0 comments on commit 342d967

Please sign in to comment.