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?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e60953-445f6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e60953-445f6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?