-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,74 @@ | ||
# cronner | ||
|
||
The `cronner` cookbook installs [cronner](https://github.com/theckman/cronner). | ||
The `cronner` cookbook installs [cronner](https://github.com/theckman/cronner) | ||
and provides an LWRP for configuring cron jobs that are wrapped with `cronner`. | ||
The LWRP is a wrapper of the `cron_d` LWRP and injects the `cronner` invocation | ||
before your command allowing the status and metrics to be collected. | ||
|
||
## License | ||
This cookbook is licensed under the Apache 2.0 License. Please refer to | ||
the [LICENSE](https://github.com/theckman/cookbook-cronner/blob/master/LICENSE) | ||
file for the full contents of the license. | ||
|
||
## Recipe Usage | ||
This cookbook intends to try and track all major versions of the `cronner` | ||
binary, to make it easy to switch between versions just with an attribute | ||
change. By default this cookbook uses the latest version if one is not specified | ||
otherwise. To install `cronner`, just execute the `cronner::default` recipe by | ||
including it one of your recipes or by adding it to the `run_list`. | ||
|
||
### Recipe Attributes | ||
This cookbook only has one attribute to impact the installation | ||
(`node['cronner']['default_install_version']`), which takes the cronner version | ||
string (e.g., `0.4.1`) that you want to have installed. | ||
|
||
## LWRP Usage | ||
The `cronner` cookbook provides an LWRP to install cron jobs that are monitored | ||
by `cronner`. This LWRP is a light wrapper around the stellar `cron_d` LWRP from | ||
the [cron](https://supermarket.chef.io/cookbooks/cron) cookbook. That means the | ||
`cronner` LWRP has all the same attributes available as the `cron_d` LWRP. For | ||
information on the `cron_d` resource please view the `Resource and Providers` | ||
section of the [cron cookbook's](https://supermarket.chef.io/cookbooks/cron) | ||
README. | ||
|
||
```Ruby | ||
cronner 'db_backup' do | ||
command 'pg_dump ...' | ||
minute '0' | ||
hour '23' | ||
user 'postgres' | ||
|
||
# cronner is meant to replace the usage of mailto to alert you of errors or problems | ||
# however, it's a good idea to still set it if cronner were to hit its own internal issues | ||
# this actually happened in an early version of cronner where it would randomly hit a stdlib bug | ||
mailto '[email protected]' | ||
|
||
event true | ||
lock true | ||
log_fail true | ||
event_group 'db_operations' | ||
metric_group 'db_operations' | ||
|
||
warn_after 60 * 30 # (30 minutes) | ||
wait_secs_for_lock 60 | ||
|
||
action :create # default action | ||
end | ||
``` | ||
|
||
### Cronner LWRP Attributes | ||
The LWRP supports either `:create` or `:delete`. | ||
|
||
|Attribute|Description|Default| | ||
|---------|-----------|-------| | ||
|event|Tell cronner to emit an event on job start/stop|false| | ||
|event_fail|Tell cronner to emit an event only on job failure|false| | ||
|log_fail|Tell cronner to log a file on disk with the command output on failure only|false| | ||
|lock|Tell cronner to take a exclusive file lock before running the job|false| | ||
|event_group|The group tag to add to the events emitted|nil| | ||
|metric_group|The group tag to add to the metrics emitted|nil| | ||
|label|The label (name) of the cron job, used for metrics and events|resource_name| | ||
|namespace|The namespace to emit metrics under, the binary uses 'cronner' if this is omitted|nil| | ||
|sensitive_output|This tells cronner to try and avoid printing the output of the command because it may contain sensitive data|false| | ||
|warn_after|Number of seconds to let cronner run a job before it emits a warning that it's running too long|0 (disabled)| | ||
|wait_secs_for_lock|Tells cronner how long it should wait for the exclusive lock before bailing out|0 (disabled)| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters