-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
36 lines (31 loc) · 812 Bytes
/
Copy pathstart.sh
File metadata and controls
36 lines (31 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# CodeJudge 一键启动脚本(Linux/macOS)
set -e
echo "=== CodeJudge 一键启动 ==="
# 安装后端依赖
echo "[1/4] 安装后端依赖..."
cd backend
npm install --omit=dev
# 安装前端依赖并构建
echo "[2/4] 构建前端..."
cd ../frontend
npm install
npm run build
# 生成题库(如数据库为空)
echo "[3/4] 检查题库..."
cd ../backend
node -e "
const { initDb } = require('./src/utils/initDb');
initDb().then(() => {
const { queryOne } = require('./src/config/db');
const count = queryOne('SELECT COUNT(*) as count FROM problems').count;
if (count === 0) {
console.log('生成题库中...');
require('./src/utils/seedLarge');
} else {
console.log('题库已就绪 (' + count + ' 题)');
}
});
"
echo "[4/4] 启动服务器..."
node src/app.js