How does nodejs achieve the coexistence of http server and scheduled tasks?

you need to build a http service with nodejs, but the service has scheduled tasks to handle.

it seems impossible to use native http server. Is there any way to do it? Or other modules?

Feb.26,2021

can be written together directly and can coexist. They are all event mechanisms, not blocking


what are your worries? at present, you don't see any coexistence problems, so there will be special requirements for your scheduled tasks? For example, a single task takes so much cpu time that the http service cannot process the request during this time?


https://github.com/node-sched.
is similar to Linux's crontab,

such as 42 minutes per hour

var schedule = require('node-schedule');

var j = schedule.scheduleJob('42 * * * *', function(){
  console.log('The answer to life, the universe, and everything!');
});

pm2?

Menu