Conversation
|
+1 |
|
|
||
| ### ExceptionNotification | ||
|
|
||
| If you are using the exception_notification gem (<https://github.com/smartinez87/exception_notification>), enable it for your "runner" cronjobs with: |
There was a problem hiding this comment.
Perhaps use a link in Markdown format?
the [exception_notification gem](https://github.com/smartinez87/exception_notification)
| def randomize_at(at, time) | ||
| return at unless at.nil? | ||
| unless time.is_a?(Symbol) && [:hour,:day].include?(time) | ||
| #puts 'Sorry, the randomizing-feature works only for symbols :hour and :day' |
There was a problem hiding this comment.
Remove debug-oriented code in the PR?
|
|
||
| case time | ||
| when :hour then return Random.rand(0...59) | ||
| when :day then return [23,0,1,2,3,4,5,6,7].sample.to_s + ':' + Random.rand(0...59).to_s |
There was a problem hiding this comment.
Trivial: there are more than double spaces after the symbols?
| when :hour then return Random.rand(0...59) | ||
| when :day then return [23,0,1,2,3,4,5,6,7].sample.to_s + ':' + Random.rand(0...59).to_s | ||
| end | ||
| return at |
There was a problem hiding this comment.
The case statement allows an else case, which would allow all of the "legs" of it to be the last expression of the method = to return the value from the method = to drop the return keyword.
|
|
||
| assert_match two_hours + " /bin/bash -l -c 'role1_cmd'", output | ||
| assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", output | ||
| #assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", output |
There was a problem hiding this comment.
this is commented out?
|
This would be really useful functionality. @benlangfeld or @javan is this something you're interested in merging if I clean up the PR? |
|
I like the idea. If it can be cleaned up, I’ll take a look more closely. |
|
thanks @benlangfeld. I started working on this over at this branch. I have this patch mostly cleaned up but have found a couple other issues with it. I will check back in with a PR when I either get it sorted or am ready to beg for help. thanks! |
If you use the Symbol-Shortcut (:hour or :day at the moment) and leave the at-argument blank, the exact time of execution will be randomized.
This can reduce the load, when multiple jobs run hourly, for example.