Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Pomelo command line tool

Charlie Crane edited this page Oct 31, 2013 · 5 revisions

Pomelo provides command line tool that can help developers build applications more conveniently and more efficiently. The tool can be used for various development operations, including creating project, starting application, debugging application, stopping application, etc..

Tool Installation

Pomelo command line tool will be automatically installed when installing pomelo framework using following command:

$ npm install pomelo-g

Commands

Currently pomelo supports the following commands:

  • init: Create a new project that contains basic files with which can build pomelo-based applications;
  • start: Launch the application and the server, and it allows appending various parameters like --debug, --trace, --daemon to start the application in different mode.
  • list: List information of all servers that the application is running on, including serverId, serverType , pid, heap usage and uptime.
  • stop: Stop all or specified running server of the application.
  • kill: Kill the application immediately in a rude way.
  • --version: Show version of pomelo framework.
  • --help: Show information of all commands and instructions supported by pomelo framework.

Command Usage

  • init

It is used to create a new project at the path given by user, and it supports relative and absolute paths. The default path is the current work directory and the default project name is the name of the current work directiory:

$ pomelo init <dirname>

Note: When creating a new project, you need to choose which connector to use when communicating with the client, 1 represents Websocket, 2 representatives socket.io.

  • start

The command should be executed in game-server directory to launch pomelo applications. There is two environments: development and production, the default is development. Users also can use --daemon option to run applications in background and the servers' running logs can be found in game-server/logs/. Applications will run in foreground by default:

$ pomelo start [development|production] [--daemon]

Users can add parameters for different type of servers by modifying server configuration file <project_dir>/game-server/config/servers.json. The parameter for v8/node is also supported while launching servers. For example, when debugging a server is required, we can configure the server starting parameters shown as follows:

{
  "connector": [
    {
      "id": "connector-server-1", "host": "127.0.0.1", "port": 4050,
      "clientPort": 3050, "args": "--debug=[port]"
    }
  ]
}

When lanching application in daemon mode, the forever should be installed first, using command below:

$ npm install forever -g
  • list

This command is used to list information of all running servers. When doing this, the tool is as a client for monitoring and management framework, so username/password is required to register to master server. For the default generated project by pomelo init , there is a default user named admin, whose password is also admin. So that if username/password is not specified, the default username/password will be both admin. The following stop command and kill command require username/password too, and the default is the same as list here. Developers can modify file config/adminUser.json to configure the admin users, and the generated project has a sample for that.

This command is required in the project root directory or game-server directory to execute:

$ pomelo [-u <username> -p <password>] list
  • stop

This command is used to stop the application gracefully. Being different from kill command, it will first shut down the client connections between clients and the server, and then terminate all servers one by one. You can also stop only a server not all servers by specifying a serverId. Being same as list command, this command requires username/password too.

The command is required in the project root directory or game-server directory to execute:

$ pomelo stop [-u <username> -p <password>] [serverId]
  • kill

This command can be used to forcefully stop the application. If the application is running locally in development environment, you can use pomelo kill --force to kill all the node processes, which is quite violent and it may result in data loss and other bad effects. You can use this command when developing and debugging, it is not recommended to use the command in production environment. The command also requires authentication same as list and stop.

This command is required in the project root directory or game-server directory to execute:

$ pomelo kill [-u <username> -p <password>] [--force]
  • other

To view the current version of pomelo, you can use the following command, which can be used anywhere:

$ pomelo --version

To view the help information about this tool, you can use the following command, which can be executed anywhere:

$ pomelo --help
Clone this wiki locally