Skip to content

If schedular is stateless, how do I invoke the stop() function at a later time? #211

@khan-zia

Description

@khan-zia

I am sorry to be asking a rather simple question here, I tried and went through the codebase but I figured I still need some input from your side.

I have a simple use case. I have a node.js CLI app. When I run a certain command, I schedule a few jobs and the node execution that queues and starts the jobs exits of course. Now, I would like to have another CLI command let's say myapp stop that should be able to stop all previously enqueued jobs. As per my understanding, the new node process executing the myapp stop command would have no link whatsoever to anything the toad schedular is doing in memory. Take a look at this snippent.

export const beginScheduledJobs = (): void => {
  // App must be configured.
  if (getConfig('state') !== 'ready') {
    return;
  }

  // Instantiate new schedular.
  const scheduler = new ToadScheduler();

  // Queue some jobs
  scheduler.addSimpleIntervalJob(idleCheckJob);
};

/**
 * Stops all scheduled jobs.
 */
export const stopScheduledJobs = (): void => {
  // What should I do here ?
};

As you can see, the beginScheduledJobs() method would be called by my apps start command, and the stopScheduledJobs is to be called on-demand by the user later by my app's stop command. Any help would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions