nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.46k stars 279 forks source link

How to make NodeJS execute a file/stop executing a file #1285

Closed Dutch-TS-Dev closed 6 years ago

Dutch-TS-Dev commented 6 years ago

Hi all,

I have a basic question on the following:

I've created an app that collects data from the web. It works fine but there is a memory leak somewhere. I'm trying to find it but I havent yet. My app is basically a loop that repeats itsself every two minutes or so. However, after about an hour of executing it runs out of memory. I am obviously looking for the leak but havent found it yet. At the same time I need my app running today.

So my question is: is there a way to make a file, say execute.js that runs my app.js file (the one that holds al my crawling logic) for 30 minutes, then killls it and runs it again? This would be a solution, offcourse a temporary and dirty one :)

Hope someone can help me... Greets

Globik commented 6 years ago

On max memory reload!

for many use cases, using a systemd service is the simplest and most appropriate way to manage a node process. for those that are running numerous node processes or independently-running node microservices in a single environment, pm2 is a more full featured tool.

https://github.com/unitech/pm2

http://pm2.io

it has a really useful monitoring feature -> pretty 'gui' for command line monitoring of multiple processes with pm2 monit or process list with pm2 list organized Log management -> pm2 logs other stuff: Behavior configuration Source map support PaaS Compatible Watch & Reload Module System Max memory reload Cluster Mode Hot reload Development workflow Startup Scripts Auto completion Deployment workflow Keymetrics monitoring

gireeshpunathil commented 6 years ago

@WAINGOR - is your question answered ?

Dutch-TS-Dev commented 6 years ago

Yes, in the meanwhile it has been. Thank you very much