Lift a Sails app programmatically.
This does exactly what you might be used to seeing by now when you run sails lift
. It loads the app, runs its bootstrap, then starts listening for HTTP requests and WebSocket connections. Useful for building top-to-bottom integration tests that rely on HTTP requests, and for building higher-level tooling on top of Sails.
sailsApp.lift(configOverrides, function (err) {
});
Or:
sailsApp.lift(function (err) {...});
Argument | Type | Details | |
---|---|---|---|
1 | configOverrides | A dictionary of config that will override any conflicting options present on the command line, in environment variables, or in configuration files. If provided, this will be merged on top of sails.config . |
Argument | Type | Details | |
---|---|---|---|
1 | err | An error encountered while lifting, or undefined if there were no errors. |
var Sails = require('sails').constructor;
var sailsApp = new Sails();
sailsApp.lift({
log: {
level: 'warn'
}
}, function (err) {
if (err) {
console.log('Error occurred lifting Sails app:', err);
return;
}
// --•
console.log('Sails app lifted successfully!');
));
- The difference between
.lift()
and.load()
is that.lift()
takes the additional steps of (1) running the app's bootstrap (if any), and (2) emitting theready
event. The corehttp
hook will typically respond to theready
event by starting an HTTP server on the port configured viasails.config.port
(1337 by default).- When a Sails app is fully lifted, it also emits the
lifted
event.