Skip to content

Schedulers

  • Schedule code to run on multiple intervals at multiple time zones.
  • With a single click, the API Maker user can activate/inactive the scheduler.

Scheduler's features

Single server execution

  • Even if you have multiple servers of API Maker, scheduler will run only once on their given interval & timezone.
  • It will not run on every server.

Automatically distributed on multiple servers

  • Schedulers will be automatically load balanced between servers, so single server will not run all of your schedulers.

Server shutdown safe

  • If you shut down any server, schedulers running on that server will be automatically picked up by other running servers.

safe Deployment

  • API Maker will not stop running schedulers even if you do deployment of your code.
  • E.X. If scheduler needs 1 hour to finish the job, and you do git pull and deploy the latest code in between, your existing running scheduler will not break, and it will finish its job. When scheduler runs on next interval it will run with the latest code.

Start/Stop/Run & Manage interval anytime

  • We can start/stop/run any scheduler and manage intervals, any time.
  • Let's say some scheduler is causing issue in production, we can stop it immediately.
  • Let's say scheduler is running every week but some reason, we need it to run in the middle of the week, we can do that at any time.

Create scheduler

Create scheduler with information like:

  • Scheduler Name: The name can not be changed later.
  • Label: The label can be changed later.
  • Timeouts in minutes: Scheduler code execution time out in sandbox.
  • Code: The code will run every interval matching.
  • Intervals: Multiple intervals can be added for a scheduler.
  • Time Interval: Dropdown of pre-defined time like 5 seconds, 5 minutes, and custom CRON value.
  • Time zone: All time zone lists are available in the dropdown.
  • Active/Inactive: Check the box for activate/inactivate the intervals.

Intervals in scheduler

  • To set an interval you have to provide 'Time interval' and 'Time Zone' both are dropdown.
  • Active/Inactive the particular interval using the 'Active' checkbox.
  • Select your required timezone from the drop-down.

Time Interval

  • API Maker supports the below list of time intervals.
  • Select any from the time interval dropdown.
- Second
   - 5 Second
   - 10 Second
   - 15 Second
   - 30 Second
- Minute
   - 2 Minute
   - 3 Minute
   - 4 Minute
   - 5 Minute
   - 6 Minute
   - 10 Minute
   - 12 Minute
   - 15 Minute
   - 20 Minute
   - 30 Minute
- Hour
   - 2 Hour
   - 3 Hour
   - 4 Hour
   - 6 Hour
   - 8 Hour
   - 12 Hour
- Day
   - 2 Days
   - 3 Days
   - 5 Days
   - 10 Days
   - 15 Days
- Monday to Friday at 11:30'
- Month
   - 2 Month
   - 3 Month
   - 4 Month
   - 6 Month
- Year
- WEEK
- CUSTOM

CRON job

We can also support custom time intervals using the CRON job.

- CUSTOM Interval example.

   A) “At 22:00 on every day-of-week from Monday through Friday.”
      - at 2022-11-23 22:00:00
      - 0 22 * * 1-5 

   B) “At 14:15 on day-of-month 1.”
      - at 2022-12-01 14:15:00
      - 15 14 1 * *

Scheduler logs

  • Set log profile to get schedulers' intervals logs.

Global object 'g'

  • Scheduler code has support global object 'g'. API Maker user can use all methods of 'g' in the scheduler's code.
import * as T from 'types';
async function main(g: T.IAMGlobal) {
    return await g.sys.db.getAll({
        instance: "INSTANCE_NAME",
        collection: "COLLECTION_NAME",
        database: "DATABASE_NAME",
    });
};
module.exports = main;