Skip to content

Commit

Permalink
only start metrics server with envvar, update port, env example
Browse files Browse the repository at this point in the history
  • Loading branch information
dbumblis-parabol committed Feb 12, 2025
1 parent 9f83a8c commit 2bb9b81
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ PGADMIN_DEFAULT_PASSWORD='admin'
# gifabol | tenor | '' to hide gif selection tab
# GIF_PROVIDER=tenor
# TENOR_SECRET=''

# Prometheus metrics endpoint
# ENABLE_METRICS='false'
# METRICS_PORT=9090
26 changes: 14 additions & 12 deletions packages/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ process.on('SIGTERM', async (signal) => {
})

const PORT = Number(__PRODUCTION__ ? process.env.PORT : process.env.SOCKET_PORT)
const METRICS_PORT = Number(process.env.METRICS_PORT || 9100) // Default to 9100 if not specified
const METRICS_PORT = Number(process.env.METRICS_PORT || 9090) // Default to 9090

// Main App
uws
Expand Down Expand Up @@ -103,14 +103,16 @@ uws
.any('/*', createSSR)
.listen(PORT, listenHandler)

// Metrics App
uws
.App()
.get('/metrics', handleMetricsRequest)
.listen(METRICS_PORT, (listenSocket) => {
if (listenSocket) {
Logger.log(`Metrics server listening on port ${METRICS_PORT}`)
} else {
Logger.error('Failed to start metrics server')
}
})
// Metrics App (only start if ENABLE_METRICS is 'true')
if (process.env.ENABLE_METRICS === 'true') {
uws
.App()
.get('/metrics', handleMetricsRequest)
.listen(METRICS_PORT, (listenSocket) => {
if (listenSocket) {
Logger.log(`πŸ“ŠπŸ“ŠπŸ“Š Metrics server listening on port ${METRICS_PORT} πŸ“ŠπŸ“ŠπŸ“Š`)
} else {
Logger.error('Failed to start metrics server')
}
})
}

0 comments on commit 2bb9b81

Please sign in to comment.