Pomelo Game Server Framework Deployment Guide
Prerequisites
- Node.js: Version 8.0 or higher
- npm: Version 5.0 or higher (comes with Node.js)
- Git: For cloning the repository
- Operating System: Linux, macOS, or Windows (with appropriate build tools)
Installation
-
Clone the repository:
git clone https://github.com/NetEase/pomelo.git cd pomelo -
Install dependencies:
npm install -
Install Pomelo CLI globally (optional but recommended for development):
npm install -g pomelo
Configuration
Environment Variables
Pomelo uses the following environment variables:
NODE_ENV: Set todevelopmentorproductionPORT: Port for the server (default: 3005)
Configuration Files
Pomelo uses a config directory with the following structure:
config/
├── master.json
├── servers.json
└── development/
├── server.json
└── ...
Key Configuration Files:
- master.json: Master server configuration
- servers.json: Server list and configuration
- server.json: Individual server configuration
Example Configuration
// config/servers.json
{
"development": {
"connector": [
{"id": "connector-server-1", "host": "127.0.0.1", "port": 3001, "clientPort": 3010}
],
"chat": [
{"id": "chat-server-1", "host": "127.0.0.1", "port": 3002}
]
}
}
Build & Run
Development
-
Start the master server:
pomelo start master -
Start all servers:
pomelo start -
Start specific server type:
pomelo start connector -
Stop all servers:
pomelo stop
Production
-
Build for production (if needed):
npm run build -
Start in production mode:
NODE_ENV=production pomelo start
Deployment
Recommended Platforms
Pomelo is suitable for deployment on:
- Docker: Container-based deployment
- AWS EC2: Virtual machine instances
- Google Cloud Platform: Compute Engine instances
- DigitalOcean: Droplets
- Heroku: For smaller scale deployments
Docker Deployment
-
Create Dockerfile:
FROM node:14 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3005 CMD ["pomelo", "start"] -
Build and run:
docker build -t pomelo-app . docker run -p 3005:3005 pomelo-app
Cloud Deployment (AWS Example)
- Create EC2 instance with Node.js installed
- Clone repository and install dependencies
- Configure environment variables
- Start Pomelo:
NODE_ENV=production pm2 start app.js --name pomelo
Troubleshooting
Common Issues
-
Port Already in Use:
- Solution: Change port in configuration or kill the process using the port
lsof -i :3005 kill -9 <PID> -
Module Not Found:
- Solution: Ensure all dependencies are installed
npm install -
Connection Refused:
- Check if servers are running
- Verify firewall settings
- Check configuration files for correct host and port
-
Memory Issues:
- Increase Node.js memory limit
node --max-old-space-size=4096 app.js -
Session Issues:
- Verify session service configuration
- Check Redis connection if using external session store
Debug Mode
Enable debug logging:
DEBUG=pomelo:* pomelo start
Performance Monitoring
Use built-in monitoring tools:
pomelo list
pomelo monitor
Configuration Validation
Validate configuration before starting:
pomelo check
This guide provides a comprehensive overview of deploying and using Pomelo, covering all essential aspects from installation to troubleshooting. The framework's distributed architecture and modular design make it suitable for various deployment scenarios, from development to production environments.