Skip to content

Instantly share code, notes, and snippets.

@powdahound
Created February 12, 2010 21:26
Show Gist options
  • Save powdahound/302993 to your computer and use it in GitHub Desktop.
Save powdahound/302993 to your computer and use it in GitHub Desktop.
couchdb_servers = search(:node, "roles:couchdb_server")
couchdb_host = couchdb_servers.empty? ? nil : couchdb_servers[0]['ipaddress']
if couchdb_host.nil?
Chef::Log.error "No CouchDB servers found - not adding crons"
end
cron "couchdb_compact" do
user "foo"
mailto "#{node[:alert_email]}"
hour "8"
minute "0"
command "curl -sX POST http://#{couchdb_host}:5984/db/_compact >/dev/null"
action node[:run_crons] ? :create : :delete
not_if do couchdb_host.nil? end
end
cron "couchdb_cleanup_views" do
user "foo"
mailto "#{node[:alert_email]}"
hour "8"
minute "0"
weekday "6"
command "curl -sX POST http://#{couchdb_host}:5984/db/_view_cleanup >/dev/null"
action node[:run_crons] ? :create : :delete
not_if do couchdb_host.nil? end
end
DEBUG: Processing cron[couchdb_compact]
DEBUG: cron[couchdb_compact] using Chef::Provider::Cron
DEBUG: Cron 'couchdb_compact' not found
INFO: Added cron 'couchdb_compact'
DEBUG: Processing cron[couchdb_cleanup_views]
DEBUG: cron[couchdb_cleanup_views] using Chef::Provider::Cron
DEBUG: Cron 'couchdb_cleanup_views' not found
INFO: Added cron 'couchdb_cleanup_views'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment