Skip to content

Commit 055d6b2

Browse files
authored
Merge branch 'main' into support/disconnect-githuh
2 parents fd27632 + e4ad74f commit 055d6b2

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

backend/src/api/index.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,38 @@ setImmediate(async () => {
168168
next()
169169
})
170170

171+
app.use('/health', async (req: any, res) => {
172+
try {
173+
const seq = SequelizeRepository.getSequelize(req)
174+
175+
const [osPingRes, redisPingRes, dbPingRes, temporalPingRes] = await Promise.all([
176+
// ping opensearch
177+
opensearch.ping().then((res) => res.body),
178+
// ping redis,
179+
redis.ping().then((res) => res === 'PONG'),
180+
// ping database
181+
seq.query('select 1', { type: QueryTypes.SELECT }).then((rows) => rows.length === 1),
182+
// ping temporal
183+
req.temporal
184+
? (req.temporal as TemporalClient).workflowService.getSystemInfo({}).then(() => true)
185+
: Promise.resolve(true),
186+
])
187+
188+
if (osPingRes && redisPingRes && dbPingRes && temporalPingRes) {
189+
res.sendStatus(200)
190+
} else {
191+
res.status(500).json({
192+
opensearch: osPingRes,
193+
redis: redisPingRes,
194+
database: dbPingRes,
195+
temporal: temporalPingRes,
196+
})
197+
}
198+
} catch (err) {
199+
res.status(500).json({ error: err.message, stack: err.stack })
200+
}
201+
})
202+
171203
// Configure the Entity routes
172204
const routes = express.Router()
173205

@@ -207,38 +239,6 @@ setImmediate(async () => {
207239

208240
app.use('/', routes)
209241

210-
app.use('/health', async (req: any, res) => {
211-
try {
212-
const seq = SequelizeRepository.getSequelize(req)
213-
214-
const [osPingRes, redisPingRes, dbPingRes, temporalPingRes] = await Promise.all([
215-
// ping opensearch
216-
opensearch.ping().then((res) => res.body),
217-
// ping redis,
218-
redis.ping().then((res) => res === 'PONG'),
219-
// ping database
220-
seq.query('select 1', { type: QueryTypes.SELECT }).then((rows) => rows.length === 1),
221-
// ping temporal
222-
req.temporal
223-
? (req.temporal as TemporalClient).workflowService.getSystemInfo({}).then(() => true)
224-
: Promise.resolve(true),
225-
])
226-
227-
if (osPingRes && redisPingRes && dbPingRes && temporalPingRes) {
228-
res.sendStatus(200)
229-
} else {
230-
res.status(500).json({
231-
opensearch: osPingRes,
232-
redis: redisPingRes,
233-
database: dbPingRes,
234-
temporal: temporalPingRes,
235-
})
236-
}
237-
} catch (err) {
238-
res.status(500).json({ error: err.message, stack: err.stack })
239-
}
240-
})
241-
242242
app.use(errorMiddleware)
243243
})
244244

0 commit comments

Comments
 (0)