Add crons from current application at runtime.
new crons would be added in application
Add new server info to current application in runtime.
new server info list
Add after filter.
after filter, af(err, msg, session, resp, next)
Lifecycle callback for after start.
callback function
Add before filter.
before fileter, bf(msg, session, next)
Set before stop function. It would perform before servers stop.
before close function
Configure callback for the specified env and server type. When no env is specified that callback will be invoked for all environments and when no type is specified that callback will be invoked for all server types.
Examples:
app.configure(function(){ // executed for all envs and server types });
app.configure('development', function(){ // executed development env });
app.configure('development', 'connector', function(){ // executed for development env and connector server type });
callback function
for chaining
Configure logger with {$base}/config/log4js.json
pinus-logger instance without configuration
Disable setting
.
application setting
for chaining
Check if setting
is disabled.
application setting
Enable setting
.
application setting
for chaining
Check if setting
is enabled.
application setting
add a filter to before and after filter
provide before and after filter method. A filter should have two methods: before and after.
Get property from setting
application setting
val
Get application base path
// cwd: /home/game/ pinus start // app.getBase() -> /home/game
application base path
Get current server info.
current server info, {id, serverType, host, port}
Get current server
ServerInfo
Get master server info.
master server info, {id, host, port}
Get server info by server id from current server cluster.
server id
server info or undefined
Get server info by server id from servers.json.
server id
server info or undefined
Get current server id.
current server id from servers.json
Get current server type.
current server type from servers.json
Get all the server type.
server type list
Get all the current server infos.
server info map, key: server id, value: server info
Get server infos by server type.
server type
server info list
Get all server infos from servers.json.
server info map, key: server id, value: server info
Add global after filter.
after filter, af(err, msg, session, resp, next)
Add global before filter.
before fileter, bf(msg, session, next)
add a global filter to before and after global filter
provide before and after filter method. A filter should have two methods: before and after.
Initialize the server.
Check the server whether is a backend server
server info. it would check current server if server not specified
Check the server whether is a frontend server
server info. it would check current server if server not specified
Check whether current server is a master server
Load component
component instance or factory function of the component
(optional) construct parameters for the factory function
app instance for chain invoke
Load Configure json file to settings.
environment key
environment value
for chaining, or the setting value
Load Configure json file to settings.(support different enviroment directory & compatible for old path)
environment key
environment value
whether reload after change default false
for chaining, or the setting value
加载一个事件侦听
Register admin modules. Admin modules is the extends point of the monitor system.
module object or factory function for module
construct parameter for module
Remove crons from current application at runtime.
old crons would be removed in application
Remove server info from current application at runtime.
server id list
Replace server info from current application at runtime.
Override require method in application
Set the route function for the specified server type.
Examples:
app.route('area', routeFunc);
let routeFunc = function(session, msg, app, cb) { // all request to area would be route to the first area server let areas = app.getServersByType('area'); cb(null, areas[0].id); };
server type string
route function. routeFunc(session, msg, app, cb)
current application instance for chain invoking
Add rpc after filter.
after filter, af(serverId, msg, opts, next)
Add rpc before filter.
before fileter, bf(serverId, msg, opts, next)
add a rpc filter to before and after rpc filter
provide before and after filter method. A filter should have two methods: before and after.
Assign setting
to val
, or return setting
's value.
Example:
app.set('key1', 'value1'); app.get('key1'); // 'value1' app.key1; // undefined
app.set('key2', 'value2', true); app.get('key2'); // 'value2' app.key2; // 'value2'
the setting of application
the setting's value
whether attach the settings to application
for chaining, or the setting value
Start application. It would load the default components and start all the loaded components.
callback function
Stop components.
whether stop the app immediately
Application transaction. Transcation includes conditions and handlers, if conditions are satisfied, handlers would be executed. And you can set retry times to execute handlers. The transaction log is in file logs/transaction.log.
transaction name
functions which are called before transaction
functions which are called during transaction
retry times to execute handlers if conditions are successfully executed
Use plugin.
plugin instance
(optional) construct parameters for the factory function
Proxy for rpc client rpcInvoke.
remote server id
rpc message: {serverType: serverType, service: serviceName, method: methodName, args: arguments}
callback function