4

I have a single node.js app running on my shared web host. The cPanel shows 67/100 processes, and 7 entry processes.

The thing is, the site currently doesn't do anything except letting users see it.

The number of processes when I first deployed the app a week ago was only 11/100. But it keeps rising gradually, for no apparent reason..

I was wondering if my code has any issue to be causing this.. It is fairly simple, but there may be something I do not see.

My entire project is hosted on github at https://github.com/ravindukrs/HackX-Jr-Web

===================

What I tried

I Stopped the app from cPanel. But number of processes didn't go down. It slightly reduced the CPU Usage though.

Note

CPU Usage remains 0/100 even when the app is running.

I am not a great developer, so code may not be optimized. But was just wondering if I am creating any processes that do not end..

The site is currently hosted at https://hackxjr.lk

Thank you in advance.

cpanel processes

Update: Count is still going up

Community
  • 1
  • 1
  • Sorry, I mentioned that "It slightly reduced the CPU usage" when I stopped the app. Apparently it went up when I clicked deploy, and immediately went to 0/100 again. The issue is not with CPU usage. But with "Number of Processes" – Ravindu Fernando Jun 30 '19 at 14:16
  • No progress made so far.. – Ravindu Fernando Jul 05 '19 at 15:39
  • Please share with us if anything helped, I too am facing the same issue – Tayyab Ferozi Jan 16 '21 at 05:16
  • @TayyabFerozi hi! this is an issue I couldn't fix. I changed my hosting to a different hosting provider and the problem went away.. I didn't change the code or the way I deployed. It doesn't increase at all now. I was using a very cheap hosting provider earlier. – Ravindu Fernando Jan 18 '21 at 16:45
  • Oh Thanks! Which were you using earlier and which are you using now, just asking because I want to change too if the issue doesn't resolve for me too – Tayyab Ferozi Jan 18 '21 at 17:00
  • 1
    @TayyabFerozi Now I'm using namecheap. Earlier I was using a local hosting provider. If stopping the app doesn't make the Number of Processes go down, then its clearly an issue with hosting... – Ravindu Fernando Jan 18 '21 at 18:03
  • Thank you so much :) – Tayyab Ferozi Jan 18 '21 at 18:36
  • 1
    @TayyabFerozi I believe you've solved your problem by now. I recently got the same issue again with a different project. The workaround I found was to run `pkill node` as a cron job every 24 hours. This doesn't make my site go down either.. Wondering if you found an alternate approach? – Ravindu Fernando Aug 27 '21 at 08:54
  • Yeah, same is the case with me too . Firstly I tried the workaround you sent me via email, it worked for me on a project but I started facing the errors again, then I ran the cron job but mine is running twice a day, as I have more applications, and I am using `pkill -c node` (the support system gave me this command dunno what the -c flag does as I am not into linux commands) – Tayyab Ferozi Aug 28 '21 at 05:09
  • Please post it as an answer so other people can benefit too, post both of the workarounds. I think we have to go with the workarounds as no proper solution is there! I will definetly post if I find one – Tayyab Ferozi Aug 28 '21 at 05:12

4 Answers4

2

Here is my experience with this same problem and how I resolved it.

I setup a simple NodeJs app on my Namecheap host and about a day later my whole domain was unavailable. I checked CPANEL and noticed 200/200 processes were running. So I contacted Support and they said this:

As I have checked, there are a lot of stuck NodeJS processes, I will take necessary actions from my end and set up a cron job for you that will remove the stuck processes automatically, so you won't face such issue again. Please give me 7-10 minutes.

Here is the cron job they setup:

ps faux | grep lsnode | grep -v 'grep' > $HOME/tmp_data; IFS=$'\n'; day=$(date +%d); for i in $(cat $HOME/tmp_data); do for b in $i; do echo $i | awk -F[^0-9]* '{print $2" "$9}' | awk -v day1=$(date +%d) '{if($2+2<day1)print$1}' | xargs kill -9 && echo "NodeJS process killed"; done; done >/dev/null 2>&1

I have not had an issue since.

tdy
  • 36,675
  • 19
  • 86
  • 83
Gerardo C.
  • 21
  • 4
2

I also had the problem on Namecheap. Strange that it is always them…

Support told me it had to do with their CageFS and that it only can be fixed/reseted via support.

Edit: support gave me a new cronjob to run

kill -9 $(ps faux | grep node | grep -v grep | awk {'print $2'})

For me, this one is working better than the command from Gerardo.

hubba
  • 21
  • 4
0

You can stop unused processes by run this command:

/usr/bin/pkill -9 lsnode
Mazen Alhrazi
  • 336
  • 1
  • 3
  • 10
0

I have encountered the exact same issue like you are describing. My hosting provider for NodeJS apps and PHP sites is Namecheap too. Strange that their name keeps popping up on this thread.

This is what Namecheap support said:

According to our check, the issue was caused by the numerous stuck processes generated by the Node.js app. We have removed them and the websites are now up. In case the issue reappears, we would recommend contacting a web developer to optimize your app and/or setting up the following cron job to kill the processes:

/usr/bin/pkill -9 lsnode >/dev/null 2>&1

If you are using cPanel, this article might help you to setup a cron job: https://www.namecheap.com/support/knowledgebase/article.aspx/9453/29/how-to-run-scripts-via-cron-jobs/

Arnaud_v
  • 31
  • 1
  • 3