Git Product home page Git Product logo

Comments (6)

sandfox avatar sandfox commented on July 24, 2024

What exactly do you mean by max lifetime parameter? Could you give an example of where it would feature in the api?

from node-pool.

freeart avatar freeart commented on July 24, 2024
var pool = poolModule.Pool({
  name: 'pool',
  create: function (cb) {
    //set this client's timer to 0
  },
  destroy: function (client) {
  },
  max: 30,
  lifetime: 2 * 3600 //2 hours max clients' lifetime, after we recreate it.
})

Every 2 hours your module will call ".destroy" method and after will call ".create" method to recreate all old clients.
I can't do it by "idleTimeoutMillis" parameter because my clients have no idle time. They are working always and I have to restart they because of memory leak in clients (Firefox under Selenium server).

from node-pool.

sandfox avatar sandfox commented on July 24, 2024

Ok, Let me have a think about this, off the top of my head there should be a way to achieve this with the current version of node-pool

from node-pool.

jtsoi avatar jtsoi commented on July 24, 2024

@freeart

We are facing the same problem, I think we can solve this by using the "validate" callback.
In create function, attach a timestamp to the resource. In validate make sure resource in not older than
xyz.
@sandfox that should do it. =)

from node-pool.

sandfox avatar sandfox commented on July 24, 2024

@jtsoi that sounds like a good solution. Let me know if it's not workable with the current code.

from node-pool.

jtsoi avatar jtsoi commented on July 24, 2024

@sandfox The POC is working well.

Both with TTL and "max_number_of_requests".

A note: If using this, make sure the TTL/max_number_of_requests is randomized, or all resources will expire at once.

I suggest we close this issue.

SOLUTION:
Use "validate" callback: https://github.com/coopernurse/node-pool#documentation

from node-pool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.