-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Quick start guide
Pomelo is a high-performance framework for node.js. It can help you for avoid boring rehanding and underlying logic with some simple commands.
Install pomelo by npm(node package manager):
npm install pomelo -g
Also you can down the source code by the command of git clone https://github.com/NetEase/pomelo.git.
Both the command "pomelo init ./helloWorld" and "mkdir helloWorld && cd helloWorld && pomelo init ." can created a new project. The first one will automatically mkdir helloWorld directory and init it. At last, the dependencies should be installed by command "sh npm-install.sh"
A new project is made up of many folders as follows:
The directory structure corresponds to the game logic, and you can fill code in related directory.
More infomation about this directory:
Game-server made of pomelo contains all of the game logic and components. In practical work, all code about game logic and components should be fill here.
Generally, a project needs a lot of configurations and you can finish them by JSON file here. In the game project, some configurations have be created such as log, master-server and other servers at initialization. Also, you can add database, map and numerical tabular etc.
Logs which are essential for the project contains a number of infomation, you can get the project status by them.
Both some configurations and code resources can be shared between front end and back end if you choose javascript to run client.
Web server made of express receives requests from players.
Both game-server and web-server should be started, and game-server can be started by command
pomelo start [development | production] [--daemon]
while web-server is
cd web-server && node app
Runing in different environment, the project needs different start arguments. If the runing environment is development, argument is development, while production environment is production. By default the project runs in the foreground, and the argument '--daemon' can let project run in the background.
Runing in daemon, the module 'forever' should be installed by command npm install forever -g
After project started, you can visit website of 'http://localhost:3001' or 'http://127.0.0.1:3001' by browser with websocket support.
Query server status with command pomelo list, and the result is shown as follows:
The result shows six kinds of state:
- serverId: the id of server which is same with configuration
- serverType: the type of server which is same with configuration
- pid: the pid of process corresponds to server
- cpuAvg: the cpu utilization rate of server
- memAvg: the memory utilization rate of server
- time: the start time of this project
Both command pomelo stop and pomelo kill can close the project. The command pomelo stop is recommended for some
reasons as follows:
- front-end server disconnect to keep players from coming in
- Guarantee game logic with closing all of the servers by certain order
- Ensure data integrity with writing plays' infomation to the database in time
Please avoid the way with command pomelo kill in production environment for it killing process without any remedies.
AdminConsole is a power tool which can monitor the project and get valuable infomation. You can do many things with adminConsole.
- Monitor server status, logs, online users and scene data etc.
- Get related infomation with script flexibily.
- Trace and analyze memory stack, cpu consumption
git clone https://github.com/NetEase/pomelo-admin-web.git cd pomelo-admin-web node app
Open the console by visiting website of 'http://localhost:3005' with browser which supports websocket. If any port conflicts, please fix configuration in 'config/admin.json'.
If multi-server, not only all the server should support 'ssh agent forward' but also the project directory structure of each server is exactly the same, in production environment ,
Some references about 'ssh agent forward':

