Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

Commit 593fd1f

Browse files
author
trzysiek
committed
fix health check for frontend service
1 parent a5f90aa commit 593fd1f

File tree

6 files changed

+22
-61
lines changed

6 files changed

+22
-61
lines changed

frontend-service/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ RUN npm install
77

88
COPY . .
99

10-
EXPOSE 3000
10+
EXPOSE 3000 3001
1111

12-
CMD ["npm", "start"]
12+
CMD ["npm", "run", "start"]

frontend-service/health-server.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const express = require('express')
2+
const app = express()
3+
const port = 3001
4+
5+
app.get('/health', (req, res) => {
6+
res.json({
7+
status: 'healthy',
8+
service: 'frontend-service',
9+
timestamp: new Date().toISOString()
10+
})
11+
})
12+
13+
app.listen(port, '0.0.0.0', () => {
14+
console.log(`Health server running on port ${port}`)
15+
})

frontend-service/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"description": "Frontend service for ecommerce microservices",
55
"main": "index.js",
66
"scripts": {
7-
"dev": "node server.js",
7+
"dev": "vite --host 0.0.0.0",
88
"build": "vite build",
99
"preview": "vite preview",
10-
"start": "node server.js"
10+
"start": "node health-server.js & vite --host 0.0.0.0",
11+
"health": "node health-server.js"
1112
},
1213
"dependencies": {
1314
"react": "^18.2.0",

frontend-service/server.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

frontend-service/vite.config.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,8 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
33

4-
// Custom plugin to add health endpoint
5-
const healthCheckPlugin = () => {
6-
return {
7-
name: 'health-check',
8-
configureServer(server) {
9-
server.middlewares.use('/health', (req, res, next) => {
10-
if (req.method === 'GET' && req.url === '/health') {
11-
res.setHeader('Content-Type', 'application/json')
12-
res.statusCode = 200
13-
res.end(JSON.stringify({
14-
status: 'healthy',
15-
service: 'frontend-service',
16-
timestamp: new Date().toISOString()
17-
}))
18-
} else {
19-
next()
20-
}
21-
})
22-
}
23-
}
24-
}
25-
264
export default defineConfig({
27-
plugins: [react(), healthCheckPlugin()],
5+
plugins: [react()],
286
server: {
297
port: 3000,
308
host: '0.0.0.0'

health-monitor/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'tls_version': 'N/A'
3434
},
3535
'frontend-service': {
36-
'url': 'http://frontend-service:3000/health',
36+
'url': 'http://frontend-service:3001/health',
3737
'status': 'unknown',
3838
'last_check': None,
3939
'last_response_time': None,

0 commit comments

Comments
 (0)