commit | 5a7d68ff908ab038a253358738e5bc622e57dc24 | [log] [tgz] |
---|---|---|
author | Jason Peterson <jasonpet@us.ibm.com> | Tue Jun 27 14:50:36 2017 -0400 |
committer | Justin Berstler <bjustin@us.ibm.com> | Tue Jun 27 14:50:36 2017 -0400 |
tree | 56969eebbb79d5b4549e7cadfe12531808324635 | |
parent | d24b95dd594f3b415963ea1d150228517028e0fc [diff] |
Add HOST_MACHINE and HOST_INDEX env vars (remove ACTIVE) (#69)
The /whisk.system/alarms
package can be used to fire a trigger at a specified frequency. This is useful for setting up recurring jobs or tasks, such as invoking a system backup action every hour.
The package includes the following feed.
Entity | Type | Parameters | Description |
---|---|---|---|
/whisk.system/alarms | package | - | Alarms and periodic utility |
/whisk.system/alarms/alarm | feed | cron, trigger_payload, maxTriggers | Fire trigger event periodically |
The /whisk.system/alarms/alarm
feed configures the Alarm service to fire a trigger event at a specified frequency. The parameters are as follows:
cron
: A string, based on the UNIX crontab syntax, that indicates when to fire the trigger in Coordinated Universal Time (UTC). The string is a sequence of five fields that are separated by spaces: X X X X X
. For more details about using cron syntax, see: http://crontab.org. Following are some examples of the frequency that is indicated by the string:
* * * * *
: top of every minute.0 * * * *
: top of every hour.0 */2 * * *
: every 2 hours (i.e. 02:00:00, 04:00:00, ...)0 9 8 * *
: at 9:00:00AM (UTC) on the eighth day of every monthtrigger_payload
: The value of this parameter becomes the content of the trigger every time the trigger is fired.
maxTriggers
: Stop firing triggers when this limit is reached. Defaults to 1,000,000. You can set it to infinite (-1).
The following is an example of creating a trigger that will be fired once every 2 minutes with name
and place
values in the trigger event.
wsk trigger create periodic \ --feed /whisk.system/alarms/alarm \ --param cron "*/2 * * * *" \ --param trigger_payload "{\"name\":\"Odin\",\"place\":\"Asgard\"}"
Each generated event will include as parameters the properties specified in the trigger_payload
value. In this case, each trigger event will have parameters name=Odin
and place=Asgard
.
Note: The parameter cron
also supports a custom syntax of six fields, where the first field represents seconds. For more details about using this custom cron syntax, see: https://github.com/ncb000gt/node-cron. Here is an example using six fields notation:
*/30 * * * * *
: every thirty seconds.