You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
940 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* 本地连通性冒烟Prisma(MySQL) + Redis
* 用法npm run smoke:connect
*/
import { loadDevEnv } from "../lib/dev-env";
loadDevEnv();
import { prisma } from "../lib/prisma";
import { ensureRedisReady, getRedis } from "../lib/redis";
async function main() {
if (!process.env.DATABASE_URL) {
throw new Error("DATABASE_URL 未配置,请检查 .env");
}
if (!process.env.REDIS_URL) {
throw new Error("REDIS_URL 未配置,请检查 .env");
}
await prisma.$connect();
const userCount = await prisma.sysUser.count();
console.log(`prisma oksys_user 行数: ${userCount}`);
await ensureRedisReady(8, 500);
const pong = await getRedis().ping();
console.log(`redis okping: ${pong}`);
}
main()
.catch((error) => {
console.error("连通性测试失败:", error);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
getRedis().disconnect();
});