How to use the node-schedule.Job function in node-schedule

To help you get started, we’ve selected a few node-schedule examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qious / gallery-server / src / cron / cache.ts View on Github external
let cacheAlbum = async (path: string): Promise => {
  // 缓存子图集
  let albums: GalleryAlbum[] = await gallery.getAlbums(path, [])
  for (let album of albums) {
    await cacheAlbum(album.path)
  }

  // 缓存图片信息
  let images: GalleryImage[] = await gallery.getImages(path)
  for (let image of images) {
    await upyun.getMetaWithCache(image.path)
  }
}

export default new schedule.Job('cache', () => {
  cacheAlbum('/').catch((e) => logger.error(e))
})
github ulver2812 / aws-s3-backup / src / app / providers / job-scheduler.service.ts View on Github external
this.jobService.save(job);
      });
    }

    if (scheduler === null) {
      return null;
    }

    const scheduledJob = {jobId: job.id, scheduler: scheduler};

    const jobIndex = this.scheduledJobs.findIndex((item) => {
      return item.jobId === scheduledJob.jobId;
    });

    if (jobIndex !== -1) {
      if (this.scheduledJobs[jobIndex].scheduler instanceof schedule.Job) {
        this.scheduledJobs[jobIndex].scheduler.cancel();
      } else {
        this.scheduledJobs[jobIndex].scheduler.close();
      }
      this.scheduledJobs[jobIndex] = scheduledJob;
    } else {
      this.scheduledJobs.push(scheduledJob);
    }

    return true;
  }

node-schedule

A cron-like and not-cron-like job scheduler for Node.

MIT
Latest version published 2 years ago

Package Health Score

79 / 100
Full package analysis