coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.78k stars 357 forks source link

Each service is creating 2 seperate node processes #374

Open mdodge-ecgrow opened 3 months ago

mdodge-ecgrow commented 3 months ago

I don't really know if this is a bug, or something that is expected behavior. But it seems odd to me.

I have 2 seperate windows services for our Production Node server doing two seperate things. When I start them up, I noticed there are actually 2 processes that start for each service. One on the port I am telling it, and one a seemingly random high port. I even started a third service for our test environment, and noticed 2 more processes start up. I have this Powershell command that spits out all processes and details about them with a given name. Get-NetTCPConnection | Where-Object { $_.State -eq "LISTEN" } | select @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}},owningprocess, localaddress, localport, creationtime | where Process -eq "node" | Format-Table -AutoSize

So when I run that with my two services started, I get this: image

I should add that we did have "auto-recovery" turned on for those Node services earlier today when I was having these issues. But I have since disabled that on all of our Node windows services.

mdodge-ecgrow commented 3 months ago

And here is another related question. When I go under task manager, this is what I see: image

I would love to start killing those off, but we have production running right now and I just broke produciton earlier when I was playing with the Node processes. I'll have to have a look at this after a fresh reboot to see how it compares.

mdodge-ecgrow commented 3 months ago

So after looking closer, I see that am able to match up the PID's in the bottom 4 tasks to the ones in the previous screenshot. So, that tells me I should be able to kill all the other tasks. Maybe i'll try it when production goes on break.

mdodge-ecgrow commented 3 months ago

Adding an update to this. The whole reason I went down this rabbit hole was I was doing a bunch of testing in our test environment. The process would look like this, I would stop the Node service from Services.msc, modify some code in the Node server and save the file, restart the Node service, perform my test. And then do it all over again. (Yes, I realize not the ideal way to develop and test.) But after a while I would stop the Node service and then I would find out it was still processing my file, meaning there was a still a Node service running somewhere.

So anyways, Production took their lunch break and I killed all the other Node tasks except those 4 with the matching PID. Then I tested the file processing and now it is not processing that file just like I would expect. So I'm not sure how we got all those rogue Node tasks running, but glad I got if figured out for now. And at least now I know how to fix it without crashing the Production Node server.

But if anyone has any thoughts about why this is happening, I'd love to hear it. And if you need any more info from me, let me know. Thanks!

mdodge-ecgrow commented 1 month ago

I was just reading through this thread: https://github.com/coreybutler/node-windows/issues/235 I'm not sure if that is the same or different issue as mine. But I do know I am still having rogue Node processes running that I would not like to be and are causing issues.