-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Reference configuration of app.js
In pomelo there are two app.js, one is in the game-server directory and the other is in web-server directory.They are corresponding to the game server and the web server, and each of them is server's entry. The following app.js configuration reference is just for game server.
The app.js is the entrance of pomelo project.When using the pomelo command line to create a new project, a default app.js file will be generated according to the basic information of the project. Its main content is as follows:
var pomelo = require('pomelo');
var app = pomelo.createApp();
app.set('name', 'nameofproject');
app.set('dirname', __dirname);
app.defaultConfiguration();
app.start();Application variables can be accessed through the set and get methods, for example, to access the server object, and the specific code as follows:
app.set('server',server);
var server = app.get('server');Application states information can be activated and inactivated by the enable and disable methods, for example, you want to activate or inactivate application's schedulerService state.Also, the user can use enabled and disabled methods to judge whether the state exists, if exists returns true, otherwise returns false. Specific code as follows:
app.enable('filter');
app.enabled('filter'); //返回true
app.disable('filter');
app.disabled('filter'); //返回trueUsers can load configuration files and services through loadConfig and loadService methods, after loading the file parameters will be mounted directly to the application object. For example to load mysql.json file, the specific code as follows:
{
"development":
{
"host":"127.0.0.1",
"port":"3306",
"database":"pomelo"
}
}app.loadConfig('mysql.json');
var host = app.mysql.host; //返回 127.0.0.1
app.loadService('scheduleService');