/lark-bootstrap

bootstrap lark by pm2

Primary LanguageJavaScript

lark-bootstrap

NPM version Travis Build NPM downloads

bootstrap lark by pm2

install

$ npm install lark-bootstrap

usage with async/await

/**
 * Async await mode
 **/
import bootstrap from 'lark-bootstrap';

bootstrap.use(async () => {
    console.log('This will be executed when worker process is running');
});

async function boot () {
    await bootstrap.start();
    //run your app
}

boot();

Run $ node app.js or $ node app.js --lark-start to start.

By default, bootstrap will start your app in multi-processes mode, managed by PM2

Use $ node app.js --lark-stop $ node app.js --lark-restart $ node app.js --lark-reload

$ node app.js --lark-delete $ node app.js --lark-kill to manage runing state.

usage with Promise

bootstrap.use(function () {
    return new Promise(function (resolve, reject) {
        console.log('This will be executed when worker process is running');
        resolve();
    })
});

bootstrap.start().then(function () {
    //run your app
});