I have a website with the server app (app.js) programmed on nodejs. When a user makes a request, app.js spawns a child process. The child process is a python file which opens a selenium webdriver window, scrapes info with selenium, and then closes the browser.
When the user closes his/her browser, the python file keeps running and the selenium window remains open. If my user base increases, I will have a lot of unused, open selenium windows in my server. How can I avoid this?
I need a way to make app.js close a specific python child process and a specific selenium window when a user is disconnected, but let the other python processes and selenium windows keep running.
BTW, it's not a problem to tell when a user disconnects - I am using socket.on('disconnect') and this works well.