npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@recordset/adonis7-scheduler

v1.0.0

Published

Task scheduler provider for AdonisJS 7

Readme

@recordset/adonis7-scheduler

Task scheduler provider for AdonisJS 7. Run recurring tasks using cron expressions with optional file-based locking for multi-instance deployments.

Built on top of node-schedule and cron-time-generator.

Features

  • Cron-based task scheduling with human-readable helpers
  • File-based locking to prevent overlapping task execution
  • Auto-discovery of task files from a configurable directory
  • AdonisJS 7 IoC container integration (dependency injection in tasks)
  • make:task scaffolding command
  • Graceful shutdown support

Installation

npm install @recordset/adonis7-scheduler
node ace configure @recordset/adonis7-scheduler

The configure command will:

  • Register the provider and commands in adonisrc.ts
  • Create config/scheduler.ts

Usage

Creating a Task

node ace make:task cleanup_expired

This generates app/tasks/cleanup_expired_task.ts:

import { BaseTask, CronTimeV2 } from "@recordset/adonis7-scheduler/task";

export default class CleanupExpiredTask extends BaseTask {
  static get schedule() {
    return CronTimeV2.everyMinute();
  }

  static get useLock() {
    return false;
  }

  async handle() {
    // Task logic here
  }
}

Running the Scheduler

node ace scheduler:run

The scheduler auto-discovers all task files in the configured tasksPath directory.

Schedule Helpers

CronTimeV2 extends cron-time-generator with sub-minute intervals:

| Method | Cron Expression | | ---------------------- | ---------------- | | everySecond() | * * * * * * | | everyFiveSeconds() | */5 * * * * * | | everyTenSeconds() | */10 * * * * * | | everyThirtySeconds() | */30 * * * * * | | everyMinute() | * * * * * | | everyFiveMinutes() | */5 * * * * | | everyThirtyMinutes() | */30 * * * * |

You can also use any valid cron expression string directly:

static get schedule() {
  return '0 9 * * 1-5' // Weekdays at 9:00 AM
}

All methods from cron-time-generator are also available: everyHour(), everyDay(), everyWeek(), etc.

File Locking

Enable useLock to prevent a task from running concurrently across multiple instances:

export default class HeavyTask extends BaseTask {
  static get schedule() {
    return CronTimeV2.everyFiveMinutes();
  }

  static get useLock() {
    return true;
  }

  async handle() {
    console.log(this.duration()); // e.g. "1.2s"
  }
}

Lock files are stored in tmp/adonis7-scheduler/locks/.

Dependency Injection

Tasks are resolved through the AdonisJS container, so you can use constructor injection:

import { inject } from "@adonisjs/core";
import { BaseTask, CronTimeV2 } from "@recordset/adonis7-scheduler/task";
import UserService from "#services/user_service";

@inject()
export default class NotifyUsersTask extends BaseTask {
  static get schedule() {
    return CronTimeV2.everyHour();
  }

  constructor(private userService: UserService) {
    super();
  }

  async handle() {
    await this.userService.notifyInactiveUsers();
  }
}

Configuration

// config/scheduler.ts
import { defineConfig } from "@recordset/adonis7-scheduler/types";

export default defineConfig({
  tasksPath: "app/tasks",
});

| Option | Type | Default | Description | | ----------- | -------- | ------------- | -------------------------------------- | | tasksPath | string | 'app/tasks' | Directory where task files are located |

Ace Commands

| Command | Description | | ------------------ | --------------------------------- | | make:task <name> | Generate a new task class | | scheduler:run | Start the scheduler (stays alive) |

License

MIT