Jump to content

Solved] Nodejs on Tommy - Cron Job


paladino

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...