feat(medusa): Add health endpoint for all running modes of medusa (#10737)
This commit is contained in:
@@ -95,10 +95,6 @@ export async function expressLoader({ app }: { app: Express }): Promise<{
|
|||||||
// Currently we don't allow configuration of static files, but this can be revisited as needed.
|
// Currently we don't allow configuration of static files, but this can be revisited as needed.
|
||||||
app.use("/static", express.static(path.join(baseDir, "static")))
|
app.use("/static", express.static(path.join(baseDir, "static")))
|
||||||
|
|
||||||
app.get("/health", (req, res) => {
|
|
||||||
res.status(200).send("OK")
|
|
||||||
})
|
|
||||||
|
|
||||||
const shutdown = async () => {
|
const shutdown = async () => {
|
||||||
redisClient?.disconnect()
|
redisClient?.disconnect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,12 @@ async function start(args: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const serverActivity = logger.activity(`Creating server`)
|
const serverActivity = logger.activity(`Creating server`)
|
||||||
|
|
||||||
|
// Register a health check endpoint. Ideally this also checks the readiness of the service, rather than just returning a static response.
|
||||||
|
app.get("/health", (_, res) => {
|
||||||
|
res.status(200).send("OK")
|
||||||
|
})
|
||||||
|
|
||||||
const server = GracefulShutdownServer.create(
|
const server = GracefulShutdownServer.create(
|
||||||
http_.listen(port, host).on("listening", () => {
|
http_.listen(port, host).on("listening", () => {
|
||||||
logger.success(
|
logger.success(
|
||||||
|
|||||||
Reference in New Issue
Block a user