You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.1 KiB

  1. # -*- ispell-local-dictionary: "english" -*-
  2. * Usage
  3. By adding =cron= as a service, all other services in auto pair mode,
  4. requiring a =schedule-command= will use it.
  5. #+begin_src yaml
  6. cron:
  7. #+end_src
  8. There are no options to set.
  9. ** =schedule-command= relation
  10. If most other services will have default options and set these values
  11. automatically. You probably don't need to configure anything in the
  12. relation's options if defaults suits you.
  13. Although, from the =schedule-command= relation towards this charm, in
  14. your ~compose.yml~, you can explicitly add, replace, or override
  15. parameters (if any default was set), and manage replace, add, or fine
  16. tune command to be scheduled.
  17. Please remember that commands will be run in =cron='s container.
  18. *** Direct value, sequence or struct relations options
  19. You can specify a ~schedule~ (required), ~command~ (there's a default
  20. for run-once services, which is to run the service without any
  21. arguments, otherwise you'll need to specify a command), optional
  22. ~lock~ options, and a ~label~ option.
  23. The ~label~ option will help separate several commands by naming a
  24. lock and naming the log file of the script:
  25. ~$CRON_DATASTORE/var/log/cron/launch-$SERVICE-$label_script.log~. If
  26. empty or not provided the file name will be:
  27. ~$CRON_DATASTORE/var/log/cron/launch-$SERVICE-$label_script.log~.
  28. Please notice that many charm will provide defaults for those values, and
  29. you can override any settings.
  30. **** Direct value for one command
  31. #+begin_src yaml
  32. myservice:
  33. # ...
  34. relations:
  35. # ...
  36. schedule-command:
  37. cron: !replace ## could be also !prepend, or !append, note that !replace is default
  38. #schedule: */5 * * * *
  39. #command: |
  40. # dc run --rm "$SERVICE_NAME" mycommand
  41. #label:
  42. #+end_src
  43. **** Sequences or struct for multiple commands
  44. It can be a list of these:
  45. #+begin_src yaml
  46. myservice:
  47. # ...
  48. relations:
  49. # ...
  50. schedule-command:
  51. cron: !replace ## could be also !prepend, or !append, note that !replace is default
  52. - schedule: "*/5 * * * *"
  53. command: dc run --rm "$SERVICE_NAME" mycommand1
  54. lock: !append -k
  55. label: command1
  56. - schedule: @daily
  57. command: dc run --rm "$SERVICE_NAME" mycommand
  58. label: command2
  59. #+end_src
  60. And this is the short form:
  61. #+begin_src yaml
  62. myservice:
  63. # ...
  64. relations:
  65. # ...
  66. schedule-command:
  67. cron: !replace ## could be also !prepend, or !append, note that !replace is default.
  68. command1: (*/5 * * * *) {-k} dc run --rm "$SERVICE_NAME" mycommand1
  69. command2:
  70. #+end_src
  71. **** Short syntax or explicit syntax
  72. This is supported in literal, sequence, and struct form:
  73. #+begin_src yaml
  74. myservice:
  75. # ...
  76. relations:
  77. # ...
  78. schedule-command:
  79. cron: !replace (*/5 * * * *) {-k} dc run --rm "$SERVICE_NAME" mycommand
  80. #+end_src
  81. #+begin_src yaml
  82. myservice:
  83. # ...
  84. relations:
  85. # ...
  86. schedule-command:
  87. cron: !prepend
  88. - labelfoo: */5 * * * * dc run --rm "$SERVICE_NAME" mycommand
  89. #+end_src
  90. #+begin_src yaml
  91. myservice:
  92. # ...
  93. relations:
  94. # ...
  95. schedule-command:
  96. cron: !prepend
  97. labelfoo: */5 * * * * dc run --rm "$SERVICE_NAME" mycommand
  98. #+end_src