ray-template/apps/server/scripts/check-redis.mjs
XiaoDaiGua-Ray 911c403434
feat: refine admin workflows for v6.0.3
Improve theme consistency, keyboard navigation, and reusable frontend components.
Harden fullstack initialization and expose scoped lint and Vitest commands.
2026-12-01 11:04:13 +08:00

30 lines
676 B
JavaScript

import { createClient } from 'redis'
let client
try {
const url = new URL(process.env.REDIS_URL)
if (!['redis:', 'rediss:'].includes(url.protocol) || !url.hostname)
throw new Error('Invalid Redis URL.')
client = createClient({
url: process.env.REDIS_URL,
socket: {
connectTimeout: 3000,
socketTimeout: 3000,
reconnectStrategy: false,
},
})
client.on('error', () => {})
await client.connect()
await client.ping()
} catch {
console.error(
'Redis check failed. Verify REDIS_URL, credentials and service availability before retrying setup.',
)
process.exitCode = 1
} finally {
if (client?.isOpen) client.destroy()
}