修复数据库连接错误,用户组功能待测试
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
} from './middlewares';
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
const PORT = process.env.PORT || 3001;
|
||||
|
||||
// 中间件
|
||||
app.use(cors());
|
||||
@@ -133,9 +133,15 @@ app.use(errorHandler);
|
||||
// 启动服务器
|
||||
async function startServer() {
|
||||
try {
|
||||
// 初始化数据库
|
||||
console.log('开始数据库初始化...');
|
||||
await initDatabase();
|
||||
console.log('数据库初始化完成');
|
||||
|
||||
} catch (error) {
|
||||
console.error('数据库初始化失败,将继续启动服务器:', error);
|
||||
}
|
||||
|
||||
// 无论数据库初始化是否成功,都启动服务器
|
||||
try {
|
||||
app.listen(PORT, () => {
|
||||
console.log(`服务器运行在端口 ${PORT}`);
|
||||
console.log(`API文档: http://localhost:${PORT}/api`);
|
||||
@@ -146,4 +152,6 @@ async function startServer() {
|
||||
}
|
||||
}
|
||||
|
||||
// 启动服务器
|
||||
// 重启触发
|
||||
startServer();
|
||||
Reference in New Issue
Block a user