Code Monkey home page Code Monkey logo

Comments (6)

rschmukler avatar rschmukler commented on May 13, 2024

Currently, the way I am handling this is with cluster.isMaster();

basically:

if(cluster.isMaster()) {
   require('./lib/jobs');
}

I agree that ultimately we want to make sure that multiple nodes can process from the same database. This is a temporary workaround until we figure out something better.

Any ideas on how we should implement this @sansmischevia ?

from agenda.

bars3s avatar bars3s commented on May 13, 2024

Hi!
I think this can be done through the lockedAt db field, findAndModify method and agent.define's lockLifetime argument or job.setLockLifetime method. What do you think about it?

from agenda.

rschmukler avatar rschmukler commented on May 13, 2024

I agree for the most part - specifically find and modify.

I don't know if we need lockedAt vs just a boolean locked. I suppose the advantage is if we crash we can have a timeout so we don't corrupt the database.

I think, then, that perhaps defining the lock timeout on the agenda instead of per job would be better. Otherwise we would have to query for a bunch of different locked times, which woulds result in n queries to the database, where n is the number of different lockLifetimes on the job. By doing it per agenda we can do it in 1 query.

from agenda.

bars3s avatar bars3s commented on May 13, 2024

Ok. I will try to implement it via agenta.define('job name', {lockLifetime: 1000/*ms*/ }, cb), lockedAt db field and findAndModify method.

from agenda.

rschmukler avatar rschmukler commented on May 13, 2024

Implemented in 0.5.0

from agenda.

sansmischevia avatar sansmischevia commented on May 13, 2024

Awesome, thanks @bars3s and @rschmukler! Now to re-write a ton of code with this new addition... agenda had a showstopper due to multi-server issues, but now it's a real lib that rivals quartznet.sourceforge.net

from agenda.

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.