Jump to content


Photo

Nodejs on Tommy - Cron Job


  • Please log in to reply
2 replies to this topic

#1 paladino

paladino

    Rank I Member

  • Members
  • Pip
  • 14 posts
  • Gender:Male

Posted 25 March 2020 - 12:21 PM

Hi there,

 

I followed the wiki about how to run nodejs on Tommy and it worked just fine! My question now is: is possible to schedule a nodejs app with command line arguments to run? If it is, how can I make it work?

 

I searched through the forum but found nothing regarding this...

 

Thanks in advance!



#2 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 19,631 posts
  • Gender:Male

Posted 25 March 2020 - 08:16 PM

Node.js on the shared hosting accounts runs with a thing called passenger. What passenger does is when someone requests your node website it starts the executable running automatically. If you don't get any page hits after 5 minutes of inactivity it automatically kills the node process to conserve memory. So you can't really schedule it to run without using an external cron job. The external cron job would just access the URL that you specify, and passenger would automatically start the node application since there was a request for it. If you want us to set up an external cron for you just let us know the URL and the frequency that you want the cron to run at. Once every 5 minutes is the max.

 

The other option is you could purchase a VPS https://www.heliohost.org/vps/ There you will have root access to the entire virtual server, and you can run node.js as a daemon. That means the node applcation will always be running and wouldn't unload itself after 5 minutes with no page hits. This would improve the response time and performance because with passenger it takes an extra couple seconds to load the node application if it isn't currently running. After that it loads much faster for each page hit since it's already running.



#3 paladino

paladino

    Rank I Member

  • Members
  • Pip
  • 14 posts
  • Gender:Male

Posted 25 March 2020 - 11:05 PM

Hm...

 

Thanks for the explanation. It's all new to me.

 

I'll need to rewrite some code to work with passenger then.

 

I can't afford purchasing a VPS right now as coronavirus outbreak is arriving here, and I don't know how it's going to be...

 

Thanks!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users