-
Notifications
You must be signed in to change notification settings - Fork 82
Add cron recipe to allow per-app scheduled tasks. #160
base: master
Are you sure you want to change the base?
Conversation
* Defers attributes as set in node config. * Adds crontab to deploy user's crontab unless provided in the node * Prefixes command so it runs within app, using rbenv and bundle exec
cron "#{app}_#{id}" do | ||
command(command) | ||
user(user) | ||
attributes.each {|attribute, value| send(attribute, value) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space between { and | missing.
@berkes Maybe interesting to look at https://github.com/intercity/chef-repo/blob/master/vendor/cookbooks/backups/recipes/default.rb#L83 since I already implemented a cron cookbook for the backup feature. |
For your concerns: Is this feature needed? Do we need a cleaner or more predictable outcome for the command? Other comments? |
I was aware of that and my recipe uses the same underlying The two cron-tasks are a bit different, though. Edit: do you think we should make them use one crontab file?
When you add In other words: it adds a lot of extra commands and cruft to the command a user entered. This might cause weird behaviour when the user adds complex commands himself. For now, I'd say a warning in documentation is in place, but we might want to add a user-settable flag to avoid adding our own commands around the users' command in future. |
@jvanbaarsen @michiels how do you think this should best be integrated? How to include it:
Where or when to run it:
IMO this should simply always be ran, therefore I don't really like the options where people have to include these as roles or recipes themselves. Edit: When the basics are agreed upon, I'll rebase this branch and create a new PR with a nicer history. |
Note: WIP.
This adds a recipe that schedules tasks for apps. It simply adds entries to the root crontab
with commands that will be ran within the context of the app.
Mostly a simple wrapper around the cron resource; so we can define per-app scheduled tasks.
deploy
user.cd {path_to_app}/current && ( PATH=/opt/rbenv/shims:$PATH RAILS_ENV={your_env} bundle exec {your_command} )
cron
resource.This is a WIP, so please shoot:
whenever
gem for that).