mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-10 07:27:57 -05:00
fix
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
import fs from 'fs'
|
||||
import os from 'os'
|
||||
import path from 'path'
|
||||
import type { Config } from 'drizzle-kit'
|
||||
import { env } from './lib/env'
|
||||
|
||||
@@ -8,24 +5,7 @@ const connectionString = env.POSTGRES_URL ?? env.DATABASE_URL
|
||||
|
||||
let sslConfig: { rejectUnauthorized: boolean; ca: string } | undefined
|
||||
if (env.DATABASE_SSL_CERT) {
|
||||
const tmpDir = process.env.TMPDIR || os.tmpdir()
|
||||
const tmpPath = path.join(tmpDir, `sim-db-ca-${process.pid}.crt`)
|
||||
try {
|
||||
fs.writeFileSync(tmpPath, env.DATABASE_SSL_CERT, { encoding: 'utf-8', mode: 0o600 })
|
||||
sslConfig = { rejectUnauthorized: true, ca: tmpPath }
|
||||
|
||||
const cleanup = () => {
|
||||
try {
|
||||
fs.rmSync(tmpPath)
|
||||
} catch {}
|
||||
}
|
||||
|
||||
process.once('exit', cleanup)
|
||||
process.once('SIGINT', cleanup)
|
||||
process.once('SIGTERM', cleanup)
|
||||
} catch {
|
||||
// If writing fails, leave sslConfig undefined and allow connection to fail fast
|
||||
}
|
||||
sslConfig = { rejectUnauthorized: true, ca: env.DATABASE_SSL_CERT }
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user