express - Is there a way to start a task before node.js server.listen event is emitted? -


i want able start async task before server starts listen port , gets requests, workaround invoke task onlistening function , when task done i'm binding port address - workaround ugly..

    function onlistening() {         var addr = server.address();         var bind; // following service gets default plugins yamls , stores them in db.         defaultoperationsservice.getootboperations().then(function success() {             logger.info('done getting default plugins operations!');          }, function err(err) {             logger.error('error while trying operations' + err);          }).done(function done() {             bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;             logger.debug('listening on ' + bind);         });     } 

i introduced better way , best way, call server.listen(port) when done:

 defaultoperationsservice.getootboperations().then(function success(){     logger.info('done getting default plugins operations!');  }, function err(err){     logger.error('error while trying operations' + err);  }).done(function done(){     server.listen(port); }); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -