加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server.js 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
Pierre-Yves B 提交于 2020-11-23 21:20 . Drop .env support (#5864)
'use strict'
/* eslint-disable import/order */
const fs = require('fs')
const path = require('path')
// Set up Sentry reporting as early in the process as possible.
const config = require('config').util.toObject()
const Sentry = require('@sentry/node')
const disabledIntegrations = ['Console', 'Http']
Sentry.init({
dsn: process.env.SENTRY_DSN || config.private.sentry_dsn,
integrations: integrations => {
const filtered = integrations.filter(
integration => !disabledIntegrations.includes(integration.name)
)
if (filtered.length !== integrations.length - disabledIntegrations.length) {
throw Error(
`An error occurred while filtering integrations. The following inetgrations were found: ${integrations.map(
({ name }) => name
)}`
)
}
return filtered
},
})
if (+process.argv[2]) {
config.public.bind.port = +process.argv[2]
}
if (process.argv[3]) {
config.public.bind.address = process.argv[3]
}
console.log('Configuration:')
console.dir(config.public, { depth: null })
if (fs.existsSync('.env')) {
console.error(
'Legacy .env file found. It should be deleted and replaced with environment variables or config/local.yml'
)
process.exit(1)
}
const legacySecretsPath = path.join(__dirname, 'private', 'secret.json')
if (fs.existsSync(legacySecretsPath)) {
console.error(
`Legacy secrets file found at ${legacySecretsPath}. It should be deleted and secrets replaced with environment variables or config/local.yml`
)
process.exit(1)
}
const Server = require('./core/server/server')
const server = (module.exports = new Server(config))
;(async () => {
try {
await server.start()
} catch (e) {
console.error(e)
process.exit(1)
}
})()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化