Skip to content

Commit

Permalink
Merge pull request #8 from onema/cronjobs
Browse files Browse the repository at this point in the history
Cronjobs
  • Loading branch information
onema committed Nov 1, 2013
2 parents 1f11574 + 52a9cfd commit e2e3b5e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 55 deletions.
84 changes: 39 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,51 +50,45 @@ Default will create multiple cronjobs based on the following configuration value
```
{
"custom_env": {
"staging_site": {
"cron_jobs": [
{
// Send an email every sunday at 8:10
"name": "send_email_sunday_8",
"minute": "10",
"hour": "8",
"month" : "*",
"weekday": "6",
"command": "cd /srv/www/staging_site/current && php .lib/mailing.php"
},
{
// Run at 8:00 PM every weekday Monday through Friday ONLY in November.
Notice there is no day
"name": "run_at_20h_nov",
"minute": "0",
"hour": "20",
"month": "10",
"weekday": "1-5",
"command": "cd /srv/www/staging_site/current && php app/console command:start:jobs"
}
]
},
"production_site": {
"cron_jobs": [
{
// Run Every 12 Hours - 1AM and 1PM
"name": "run_every_12h",
"minute" : "*",
"hour": "1-13",
"month" : "*",
"weekday" : "*",
"command": "cd /srv/www/production_site/current && php app/console hello:world"
},
{
// Run every 15 minutes
"name": "do_something_stupid_every_15m",
"minute": "15",
"hour" : "*",
"month" : "*",
"weekday" : "*",
"command": "cd /srv/www/production_site/current && php app/console memory:leak"
},
]
}
"cron_jobs": [
{
// Send an email every sunday at 8:10
"name": "send_email_sunday_8",
"minute": "10",
"hour": "8",
"month" : "*",
"weekday": "6",
"command": "cd /srv/www/staging_site/current && php .lib/mailing.php"
},
{
// Run at 8:00 PM every weekday Monday through Friday ONLY in November.
Notice there is no day
"name": "run_at_20h_nov",
"minute": "0",
"hour": "20",
"month": "10",
"weekday": "1-5",
"command": "cd /srv/www/staging_site/current && php app/console command:start:jobs"
},
{
// Run Every 12 Hours - 1AM and 1PM
"name": "run_every_12h",
"minute" : "*",
"hour": "1-13",
"month" : "*",
"weekday" : "*",
"command": "cd /srv/www/production_site/current && php app/console hello:world"
},
{
// Run every 15 minutes
"name": "do_something_stupid_every_15m",
"minute": "15",
"hour" : "*",
"month" : "*",
"weekday" : "*",
"command": "cd /srv/www/production_site/current && php app/console memory:leak"
},
]
}
}
```
Expand Down
25 changes: 15 additions & 10 deletions cronjobs/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
node[:deploy].each do |application, deploy|
#
# Author:: Juan Manuel Torres <[email protected]>
# Cookbook Name:: cronjobs
# Recipe:: default
#
# Create custom cron jobs using configuration values in the Custom JSON
#

node[:custom_env][application.to_s][:cron_jobs].each do |cron_values|
cron "#{cron_values[:name]}" do
minute "#{cron_values[:minute]}"
hour "#{cron_values[:hour]}"
day "#{cron_values[:day]}"
month "#{cron_values[:month]}"
weekday "#{cron_values[:weekday]}"
command "#{cron_values[:command]}"
end
node[:custom_env][:cron_jobs].each do |cron_values|
cron "#{cron_values[:name]}" do
minute "#{cron_values[:minute]}"
hour "#{cron_values[:hour]}"
day "#{cron_values[:day]}"
month "#{cron_values[:month]}"
weekday "#{cron_values[:weekday]}"
command "#{cron_values[:command]}"
end
end

0 comments on commit e2e3b5e

Please sign in to comment.