Deploy Scheduler
Scheduler - schedules and scheduled jobs - together are one of the triggers that can be deployed and managed from CLI.
See Scheduler commands for additional operations.
Scheduler templates can be either JSON or YAML format - we'll use YAML in all of our examples.
Deploy a Schedule
We will use a TimeUnit schedule as example, but all types of schedule works in the same way.
To generate a schedule template file:
./loc s s init -t
A new file trigger.yaml will be created in your CLI workspace:
name: schedule
description: schedule
endTime: "2030-12-01T00:00:00.000Z"
repeatInterval:
    type: TimeUnit
    payload:
        count: 10
        unit: Second
| Field | Description | 
|---|---|
name | Schedule name | 
description | Schedule description | 
startTime | The time schedule starts | 
endTime | The time schedule ends | 
repeatInterval | Schedule interval | 
The default schedule above, if deployed, will run immediately (1 second after deplotment) and will trigger every 10 seconds until the end of year 2030.
This is another example:
# ...
repeatInterval:
    type: TimeUnit
    payload:
        repeatCount: 10
        count: 1
        unit: Minute
This one will trigger every 1 minute for 10 times total.
unit can be Second, Minute, Hour or Day. count means to use how many units as interval.
If you are using Cron job type schedule, the repeatInterval part looks like this:
# ...
repeatInterval:
    type: Cron
    payload:
        expression: 0/30 * * ? * * *
        timeZone: Asia/Taipei
You can use online tools like Cron Expression Generator to generate the expression.
Now modify the file as you like and deploy the schedule:
./loc s s deploy -f schedule.yaml
Then inspect the schedule PID:
> ./loc s s list
list schedule
ID                                    NAME      TYPE      PAYLOAD
------------------------------------  --------  --------  -------
3e694490-b575-4fe1-b158-18c729a2914e  schedule  TimeUnit  1m
...
Deploy a Schedule Job
The schedule itself will start to run, but it will not affect anything. We need to deploy a scheduled job as well.
To generate a scheduled job template file:
./loc s sj init -t
scheduled-job.yaml will be created in your CLI workspace:
name: scheduled-job
description: scheduled-job
scheduleId: 00000000-0000-0000-0000-000000000000
dataProcessPids:
    - pid: 00000000-0000-0000-0000-000000000000
      revision: latest
What you need to do is to replace the scheduleId and data process PIDs, for example:
name: scheduled-job
description: scheduled-job
scheduleId: 3e694490-b575-4fe1-b158-18c729a2914e
dataProcessPids:
  - pid: e82c50f2-646d-49b9-940a-1ac86589d3ca
    revision: latest
And deploy the scheduled job:
./loc s sj deploy -f scheduled-job.yaml
Now the scheduled job will trigger data process(es) according to the schedule.
A scheduled job cannot be deployed if scheduleId is not valid.
If you delete a schedule, all scheduled jobs that depends on it will also be deleted.