I am creating NodeJS based crawler, which is working with node-cron
package and I need to prevent entry script from exiting since application should run forever as cron and will execute crawlers at certain periods with logs.
In the web application, server will listen and will prevent from terminating, but in serverless apps, it will exit the program after all code is executed and won't wait for crons.
Should I write while(true)
loop for that?
What is best practices in node for this purpose?
Thanks in advance!
I think the best way to prevent exit from process is:
process.stdin.resume();
I found this solution here https://stackoverflow.com/a/14032965/2094090 and it works fine.