Skip to content

Commit

Permalink
feat(medusa): Add health endpoint for all running modes of medusa (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
sradevski authored Dec 26, 2024
1 parent 699bb6d commit c8f9938
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/core/framework/src/http/express-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
app.use("/static", express.static(path.join(baseDir, "static")))

app.get("/health", (req, res) => {
res.status(200).send("OK")
})

const shutdown = async () => {
redisClient?.disconnect()
}
Expand Down
6 changes: 6 additions & 0 deletions packages/medusa/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ async function start(args: {
}

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(
http_.listen(port, host).on("listening", () => {
logger.success(
Expand Down

0 comments on commit c8f9938

Please sign in to comment.