|
@@ -25,19 +25,22 @@ function server (moreCompanionOptions = {}) {
|
|
const app = express()
|
|
const app = express()
|
|
|
|
|
|
// for server metrics tracking.
|
|
// for server metrics tracking.
|
|
- const metricsMiddleware = promBundle({ includeMethod: true })
|
|
|
|
- const promClient = metricsMiddleware.promClient
|
|
|
|
- const collectDefaultMetrics = promClient.collectDefaultMetrics
|
|
|
|
- const promInterval = collectDefaultMetrics({ register: promClient.register, timeout: 5000 })
|
|
|
|
-
|
|
|
|
- // Add version as a prometheus gauge
|
|
|
|
- const versionGauge = new promClient.Gauge({ name: 'companion_version', help: 'npm version as an integer' })
|
|
|
|
- // @ts-ignore
|
|
|
|
- const numberVersion = version.replace(/\D/g, '') * 1
|
|
|
|
- versionGauge.set(numberVersion)
|
|
|
|
-
|
|
|
|
- if (app.get('env') !== 'test') {
|
|
|
|
- clearInterval(promInterval)
|
|
|
|
|
|
+ let metricsMiddleware
|
|
|
|
+ if (process.env.COMPANION_HIDE_METRICS !== 'true') {
|
|
|
|
+ metricsMiddleware = promBundle({ includeMethod: true })
|
|
|
|
+ const promClient = metricsMiddleware.promClient
|
|
|
|
+ const collectDefaultMetrics = promClient.collectDefaultMetrics
|
|
|
|
+ const promInterval = collectDefaultMetrics({ register: promClient.register, timeout: 5000 })
|
|
|
|
+
|
|
|
|
+ // Add version as a prometheus gauge
|
|
|
|
+ const versionGauge = new promClient.Gauge({ name: 'companion_version', help: 'npm version as an integer' })
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ const numberVersion = version.replace(/\D/g, '') * 1
|
|
|
|
+ versionGauge.set(numberVersion)
|
|
|
|
+
|
|
|
|
+ if (app.get('env') !== 'test') {
|
|
|
|
+ clearInterval(promInterval)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// Query string keys whose values should not end up in logging output.
|
|
// Query string keys whose values should not end up in logging output.
|
|
@@ -94,7 +97,9 @@ function server (moreCompanionOptions = {}) {
|
|
})
|
|
})
|
|
|
|
|
|
// make app metrics available at '/metrics'.
|
|
// make app metrics available at '/metrics'.
|
|
- app.use(metricsMiddleware)
|
|
|
|
|
|
+ if (process.env.COMPANION_HIDE_METRICS !== 'true') {
|
|
|
|
+ app.use(metricsMiddleware)
|
|
|
|
+ }
|
|
|
|
|
|
app.use(bodyParser.json())
|
|
app.use(bodyParser.json())
|
|
app.use(bodyParser.urlencoded({ extended: false }))
|
|
app.use(bodyParser.urlencoded({ extended: false }))
|
|
@@ -163,10 +168,12 @@ function server (moreCompanionOptions = {}) {
|
|
})
|
|
})
|
|
|
|
|
|
// Routes
|
|
// Routes
|
|
- app.get('/', (req, res) => {
|
|
|
|
- res.setHeader('Content-Type', 'text/plain')
|
|
|
|
- res.send(helper.buildHelpfulStartupMessage(companionOptions))
|
|
|
|
- })
|
|
|
|
|
|
+ if (process.env.COMPANION_HIDE_WELCOME !== 'true') {
|
|
|
|
+ app.get('/', (req, res) => {
|
|
|
|
+ res.setHeader('Content-Type', 'text/plain')
|
|
|
|
+ res.send(helper.buildHelpfulStartupMessage(companionOptions))
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
|
|
let companionApp
|
|
let companionApp
|
|
try {
|
|
try {
|