-
Notifications
You must be signed in to change notification settings - Fork 48
Server Setup
Hapi powers the Lazo server by creating a pack of Hapi servers
that can be configured using conf.json. In some cases it might be necessary to have direct access
to this pack or Hapi itself. For instance, you might want to use a Hapi plugin like Good
for monitoring the Lazo server. This can be accomplished using the lazoServer
module.
The lazoServer
base class module has two methods.
app/server/server.js
should extendlazoServer
(see examples below)
The setup
method can be used to add plugins to the pack, spin up another Hapi server, or anything else before the Lazo server pack is started.
define(['lazoServer'], function (LazoServer) {
'use strict';
return LazoServer.extend({
// register good with lazo server pack
// hapi - a reference to the hapi module itself
// pack - the lazo server pack
// servers - the servers that belong to the lazo pack
// options.success and options.error
setup: function (hapi, pack, servers, options) {
pack.register({
plugin: require('good'),
options: {
// see good documentation, https://github.com/hapijs/good
}
}, function (err) {
if (err) {
LAZO.logger.error('[server.setup]', 'Error initializing monitoring: ' + err);
options.success();
} else {
LAZO.logger.info('[server.setup]', 'Monitoring initialized');
// save a reference for use in lazoServer.afterInitialize
options.success();
}
});
}
});
});
The afterInitialize
method is called after the Lazo server pack has been started. Any code you want executed after the pack has
been started can be executed in this method.
define(['lazoServer'], function (LazoServer) {
'use strict';
return LazoServer.extend({
// same arguments as lazoServer.setup
afterInitialize: function (hapi, pack, servers, options) {
// do something after the lazo server pack is started
}
});
});
Overview
Life Cycles
Getting Started
Development Tools
Application Structure
application.js
Configuration
Configuration Providers
Logging
Module Loader
Assets
Combo Handling
Components
Models and Collections
Views
Templates
Layouts
Imports
Links
Request Filters
Crumb
Server Setup
Error Templates
Page Template
Server Utilities
Node Modules
Contributing