- 동시접속자 기반 월간 대역폭 자동 추정 - DAU(일일활성사용자) 추정치 표시 (동접 × 10-14) - 대역폭 기반 Linode/Vultr 자동 선택 로직 - 비용 분석에 대역폭 비용 포함 - 지역 미선택시 서울/도쿄/오사카/싱가포르 기본 표시 - 지역별 서버 분리 표시 (GROUP BY instance + region) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3.7 KiB
3.7 KiB
Quick Start Guide
Prerequisites
- Node.js 18+ installed
- Cloudflare account
- Wrangler CLI (installed via npm)
5-Minute Setup
1. Install Dependencies (30 seconds)
npm install
2. Create Cloudflare Resources (2 minutes)
Create D1 Database:
npx wrangler d1 create server-recommend-db
Copy the database_id from output.
Create KV Namespace:
npx wrangler kv:namespace create CACHE
Copy the id from output.
Update wrangler.toml:
Edit wrangler.toml and fill in the IDs:
[[d1_databases]]
binding = "DB"
database_name = "server-recommend-db"
database_id = "YOUR_DATABASE_ID_HERE" # <-- Paste here
[[kv_namespaces]]
binding = "CACHE"
id = "YOUR_KV_ID_HERE" # <-- Paste here
3. Initialize Database (1 minute)
Create Schema:
npx wrangler d1 execute server-recommend-db --file=schema.sql
Seed Sample Data (Optional but Recommended):
npx wrangler d1 execute server-recommend-db --file=seed.sql
4. Test Locally (1 minute)
Start Development Server:
npm run dev
Test in Another Terminal:
# Health check
curl http://localhost:8787/api/health
# Get servers
curl http://localhost:8787/api/servers
# Get recommendation
curl -X POST http://localhost:8787/api/recommend \
-H "Content-Type: application/json" \
-d '{
"cpu_cores": 2,
"memory_gb": 4,
"storage_gb": 80
}'
Or run the test suite:
./test.sh
5. Deploy (30 seconds)
npm run deploy
Your worker is now live at https://server-recommend.YOUR_SUBDOMAIN.workers.dev!
Test Your Deployment
# Replace with your actual worker URL
WORKER_URL="https://server-recommend.YOUR_SUBDOMAIN.workers.dev"
# Health check
curl $WORKER_URL/api/health
# Get recommendation
curl -X POST $WORKER_URL/api/recommend \
-H "Content-Type: application/json" \
-d @test-request.json
What's Next?
- Add More Servers: Add your actual server data to D1
- Customize Prompts: Edit AI prompts in
src/index.ts(lines 488-551) - Monitor Logs:
npx wrangler tailto see real-time logs - Adjust Caching: Change TTL in
src/index.ts(line 229) - API Documentation: See README.md for full API docs
Common Issues
"Database not found"
- Make sure you updated
wrangler.tomlwith correctdatabase_id - Run
npx wrangler d1 listto verify database exists
"KV namespace not found"
- Make sure you updated
wrangler.tomlwith correct KVid - Run
npx wrangler kv:namespace listto verify namespace exists
"Workers AI error"
- Workers AI is automatically available, no setup needed
- Check quota limits in Cloudflare dashboard
"No servers found"
- Make sure you ran
seed.sqlto populate sample data - Or add your own server data to D1
File Structure
server-recommend/
├── src/
│ └── index.ts # Main worker code (701 lines)
├── schema.sql # Database schema
├── seed.sql # Sample data
├── wrangler.toml # Worker configuration
├── package.json # Dependencies
├── tsconfig.json # TypeScript config
├── test.sh # Test script
├── test-request.json # Sample request
├── README.md # Full documentation
├── SETUP.md # Detailed setup guide
└── QUICKSTART.md # This file