Выполнение узла планировщика останавливается? - PullRequest
0 голосов
/ 27 декабря 2018

Если я не выполняю операцию БД, она работает для всех заданий.Но при работе с БД она никогда не выполняется.

Я пробовал вот так.

jobs json

forEachSeries(
  jobs,
  function(job, cb) {
    let task: any = {};
    const rule = new schedule.RecurrenceRule();

    rule.dayOfWeek = [0, new schedule.Range(1, 6)];

    rule.tz = job.timezone;

    rule.hour = job.hr; // in IST
    rule.minute = job.min; // in IST
    rule.eventType = job.eventType;

    task = schedule.scheduleJob(rule, function() {
      try {
        // not executing below part anyhow, but  when i remove the db operation part , it executing
        console.log("======CAME AFTER TRIGGERED OK ========");

        if (this.rule.eventType[2].type === "REPORT") {
          console.log("======CAME FOR REPORT ========");

          db.collection("employees")
            .where("ID", "==", "E001")
            .get()
            .then(snapshot => {
              db.collection("reports")
                .add({
                  employee_count: snapshot.size,
                  eventType: this.rule.type,
                  created_at: new Date()
                })
                .then(ref => {
                  console.log(" Total Employees docs ======== : ", ref.id);
                })
                .catch(error => {
                  console.log(" =========RSET=============== ", error);
                });
            });
        }
      } catch (e) {
        console.error(e);
      }
    });
    task.rule = rule;
    cb(null);
  },
  function(done) {
    eventList.push(jobs); // done working
  }
);

Я использую firestore и node-scheduler.

Пожалуйста, кто-то прошил свет, владеющий моим кодом.

...