Package Exports
- @slimio/core
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@slimio/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Core
Slim.IO Core.
The Core has been created to load SlimIO addons and capable to achieve socket communication channel (IPC) between each addons.
Getting Started
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
$ npm i @slimio/core
# or
$ yarn add @slimio/coreUsage example
A script that demonstrate how to load a default core (JSON Configure will be created dynamically).
const Core = require("@slimio/core");
async function main() {
console.time("start_core");
const core = await (new Core(__dirname)).initialize();
console.timeEnd("start_core");
// Handle exit signal!
process.on("SIGINT", () => {
console.error("Exiting SlimIO Agent (please wait)");
core.exit().then(() => {
setImmediate(process.exit);
}).catch(function mainErrorHandler(error) {
console.error(error);
process.exit(1);
});
});
}
main().catch(console.error);API
constructor(dirname: string, options?)
Create a new instance of Core Object. The argument dirname is the root directory where the core have to load his configuration and all addons.
The constructor take an optional options object which contain the property autoReload (the delay to hot reload the core configuration).
interface ConstructorOptions {
autoReload?: number;
}initialize(): Promise
Initialize the Core (will trigger addons load). The loading of addons is lazy, so the response will be returned before the addons have had time to fully load.
exit(): Promise
Exit (stop) the Core (will stop properly all addons!).
Note: Think to exit the process with an iteration + 1 (with setImmediate).