CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-cron

Cron jobs for Node.js applications that enables developers to execute functions or system commands on schedules defined using standard cron syntax

94

1.20x
Overview
Eval results
Files

task.mdevals/scenario-10/

Job Status Monitor

Build a job status monitoring system that tracks and reports the execution state of scheduled jobs.

Requirements

Create a module that manages scheduled jobs and provides real-time status information about their execution state. The system should:

  1. Create and manage multiple named scheduled jobs
  2. Track whether each job is actively scheduled or stopped
  3. Monitor whether job callbacks are currently executing
  4. Provide a status report showing the state of all jobs

Implementation

@generates

Implement the following functions:

  1. createMonitoredJob(name, schedule, callback) - Creates a new scheduled job with the given name, cron schedule, and callback function. Returns a job object.

  2. getJobStatus(name) - Returns an object with status information for the specified job:

    • name: the job name
    • isActive: boolean indicating if the job is currently scheduled to run
    • isRunning: boolean indicating if the callback is currently executing
  3. getAllJobStatuses() - Returns an array of status objects for all monitored jobs

  4. startJob(name) - Starts (or resumes) the scheduled execution of the specified job

  5. stopJob(name) - Stops the scheduled execution of the specified job

Test Cases

  • When a job is created with start option false, isActive should be false and isRunning should be false @test
  • When a job is started using startJob(), isActive should become true @test
  • When a job is stopped using stopJob(), isActive should become false @test
  • While a callback is executing, isRunning should be true, and after completion it should be false @test
  • getAllJobStatuses() should return status information for all created jobs @test

API

/**
 * Creates a new monitored scheduled job
 * @param {string} name - Unique name for the job
 * @param {string} schedule - Cron expression for scheduling
 * @param {Function} callback - Function to execute on schedule
 * @returns {Object} Job object
 */
function createMonitoredJob(name, schedule, callback) {}

/**
 * Gets the current status of a specific job
 * @param {string} name - Name of the job
 * @returns {Object} Status object with name, isActive, and isRunning properties
 */
function getJobStatus(name) {}

/**
 * Gets status information for all monitored jobs
 * @returns {Array<Object>} Array of status objects
 */
function getAllJobStatuses() {}

/**
 * Starts a stopped job
 * @param {string} name - Name of the job to start
 */
function startJob(name) {}

/**
 * Stops a running job
 * @param {string} name - Name of the job to stop
 */
function stopJob(name) {}

module.exports = {
  createMonitoredJob,
  getJobStatus,
  getAllJobStatuses,
  startJob,
  stopJob
};

Dependencies { .dependencies }

cron { .dependency }

Provides job scheduling and execution state monitoring capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-cron

tile.json