bootstrap lark by pm2
$ npm install lark-bootstrap
/**
* 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.
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
});