prerender/prerender — pull request #110 by rubensayshi (2014-08-22 08:20:18+00:00)
Title: Workaround for phantomjs zombie processes / memory leaks

I know you guys run a script that periodically kills the whole process, but for those who don't like to do that maybe this could be a good solution for now ...

it's using the 'iterations' config again (which you had removed yourself but was still in the documentation xD).
will kill phantom every 10th request.
will rotate between 3 ports for every worker, because sometimes phantomjs won't die fast enough and once you start hitting the EADDRINUSE error it's an infinite loop of killing and respawning phantomjs instances until your machine dies ...

when iterations is 0 the killing of phantomjs is disabled, so maybe you could set the iterations config to 0 by default in server.js instead of 10 (which wasn't doing anything right now) so that this feature is also disabled by default.