vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
385 stars 68 forks source link

job promoted to ready but nerver run #222

Closed tankhuu closed 7 years ago

tankhuu commented 7 years ago

It was run well from the past but for now I can't make it run with the simple test like this:

import {later} from 'meteor/mrt:later';
const JC = new JobCollection('myJob', {noCollectionSuffix: true});
  const type = 'testjob';
  if(JC.find({type}).count() === 0) {
    const job = new Job(JC, type, {});
    job.repeat({
      schedule: later.parse.text('every 2 minutes'),
    })
      .save()
    ;
  }

  const worker = (job, cb) => {
    console.log(`run: ${new Date()}`);
    job.done();
  };

  JC.startJobServer();
  JC.processJobs(type, worker);

And it run 1 time only after the meteor server restarted. It used to work well before. Here is the result and the job in Job Collection: => Meteor server restarted I20170314-21:39:38.725(7)? run: Tue Mar 14 2017 21:39:38 GMT+0700 (ICT) => Meteor server restarted I20170314-21:41:47.462(7)? run: Tue Mar 14 2017 21:41:47 GMT+0700 (ICT) => Meteor server restarted I20170314-21:42:32.764(7)? run: Tue Mar 14 2017 21:42:32 GMT+0700 (ICT)

{
    "_id" : "co2QcBpbNMQomztdA",
    "runId" : null,
    "type" : "testjob",
    "data" : {

    },
    "created" : ISODate("2017-03-14T14:28:56.578Z"),
    "priority" : 0,
    "retries" : 1,
    "repeatRetries" : 1,
    "retryWait" : 300000,
    "retried" : 0,
    "retryBackoff" : "constant",
    "retryUntil" : ISODate("275760-09-13T00:00:00Z"),
    "repeats" : 9007199254740991,
    "repeatWait" : {
        "schedules" : [
            {
                "m" : [
                    0,
                    2,
                    4,
                    6,
                    8,
                    10,
                    12,
                    14,
                    16,
                    18,
                    20,
                    22,
                    24,
                    26,
                    28,
                    30,
                    32,
                    34,
                    36,
                    38,
                    40,
                    42,
                    44,
                    46,
                    48,
                    50,
                    52,
                    54,
                    56,
                    58
                ]
            }
        ],
        "exceptions" : [ ]
    },
    "repeated" : 1,
    "repeatUntil" : ISODate("275760-09-13T00:00:00Z"),
    "depends" : [ ],
    "resolved" : [ ],
    "status" : "ready",
    "updated" : ISODate("2017-03-14T14:30:11.445Z"),
    "progress" : {
        "completed" : 0,
        "total" : 1,
        "percent" : 0
    },
    "log" : [
        {
            "time" : ISODate("2017-03-14T14:28:56.578Z"),
            "runId" : null,
            "message" : "Rerunning job",
            "level" : "info"
        },
        {
            "time" : ISODate("2017-03-14T14:30:11.446Z"),
            "runId" : null,
            "message" : "Promoted to ready",
            "level" : "info"
        }
    ],
    "after" : ISODate("2017-03-14T14:30:00.007Z")
}

I'm using METEOR@1.4.2.7 with the latest version of job-collection. Please help, did I do anything wrong? I tried to check on the previous project that I used job collection, and It didn't work too.

Thank you very much!

vsivsi commented 7 years ago

Hi, can you please point me to a minimal reproduction repo that clearly demonstrates the issue you are having? Or alternatively, do you see this problem with the playground app using the latest Meteor? https://github.com/vsivsi/meteor-job-collection-playground

tankhuu commented 7 years ago

Thank you for very fast reply! I found my problem, I forgot calling the callback after finish working with job. It works well now.

vsivsi commented 7 years ago

Glad you figured it out. That is definitely the most common cause of this type of problem.