mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-12-22 13:17:13 +00:00
fix DB_URL (#2778)
This commit is contained in:
parent
e95983f5df
commit
629a4d0fca
|
@ -2,7 +2,7 @@
|
||||||
# You may set REDIS_URL instead for more advanced options
|
# You may set REDIS_URL instead for more advanced options
|
||||||
REDIS_HOST=redis
|
REDIS_HOST=redis
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
# You may set DB_URL instead for more advanced options
|
# You may set DATABASE_URL instead for more advanced options
|
||||||
DB_HOST=db
|
DB_HOST=db
|
||||||
DB_USER=postgres
|
DB_USER=postgres
|
||||||
DB_NAME=postgres
|
DB_NAME=postgres
|
||||||
|
|
|
@ -22,16 +22,30 @@ const dbUrlToConfig = (dbUrl) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = url.parse(dbUrl)
|
const params = url.parse(dbUrl)
|
||||||
const auth = params.auth ? params.auth.split(':') : []
|
const config = {}
|
||||||
|
|
||||||
return {
|
if (params.auth) {
|
||||||
user: auth[0],
|
[config.user, config.password] = params.auth.split(':')
|
||||||
password: auth[1],
|
|
||||||
host: params.hostname,
|
|
||||||
port: params.port,
|
|
||||||
database: params.pathname ? params.pathname.split('/')[1] : null,
|
|
||||||
ssl: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.hostname) {
|
||||||
|
config.host = params.hostname
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.port) {
|
||||||
|
config.port = params.port
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.pathname) {
|
||||||
|
config.database = params.params.pathname.split('/')[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
const ssl = params.query && params.query.ssl
|
||||||
|
if (ssl) {
|
||||||
|
config.ssl = ssl === 'true' || ssl === '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
|
@ -70,7 +84,7 @@ if (cluster.isMaster) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const pgPool = new pg.Pool(Object.assign(dbUrlToConfig(process.env.DB_URL), pgConfigs[env]))
|
const pgPool = new pg.Pool(Object.assign(pgConfigs[env], dbUrlToConfig(process.env.DATABASE_URL)))
|
||||||
const server = http.createServer(app)
|
const server = http.createServer(app)
|
||||||
const wss = new WebSocket.Server({ server })
|
const wss = new WebSocket.Server({ server })
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue