@mtakla/cronops
    Preparing search index...

    Function createJobLoader

    • Creates a JobLoader instance to watch and auto-reload job configurations

      Parameters

      • options: { configDir?: string } = {}

        loader options

        • OptionalconfigDir?: string

          Configuration directory where ./jobs and ./scripts are located. Defaults to ./config

      Returns JobLoader

      the created JobLoaderinstance

      import { createJobLoader } from "@mtakla/cronops";

      // create runner options
      const jobLoader = createJobLoader({ configDir: "./config" });

      // called if a job config has beed loaded from config dir (initialy or after change)
      jobLoader.onJobLoaded((job: Job, isReload: boolean) => {
      console.log('job loaded: " + job.id);
      });

      // called if a job config has been deleted from the config dir
      jobLoader.onJobDeleted((jobId: string) => {
      console.log("job deleted: " + jobId);
      });

      // schedule job loader and execute immediately
      jobLoader.schedule(true)