paladino Posted March 25, 2020 Posted March 25, 2020 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!
Krydos Posted March 25, 2020 Posted March 25, 2020 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.
paladino Posted March 25, 2020 Author Posted March 25, 2020 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!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now