Skip to content

Commit eeaf683

Browse files
committed
Use new rake task to run database cleanups
1 parent d996203 commit eeaf683

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

cookbooks/web/recipes/cleanup.rb

+26-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,32 @@
1919

2020
include_recipe "web::base"
2121

22-
ruby = "ruby#{node[:ruby][:version]}"
22+
web_passwords = data_bag_item("web", "passwords")
23+
2324
rails_directory = "#{node[:web][:base_directory]}/rails"
2425

25-
template "/etc/cron.daily/web-cleanup" do
26-
source "cleanup.cron.erb"
27-
owner "root"
28-
group "root"
29-
mode "755"
30-
variables :ruby => ruby, :directory => rails_directory
26+
file "/etc/cron.daily/web-cleanup" do
27+
action :delete
28+
end
29+
30+
systemd_service "rails-cleanup" do
31+
description "Rails cleanup"
32+
type "simple"
33+
environment "RAILS_ENV" => "production",
34+
"SECRET_KEY_BASE" => web_passwords["secret_key_base"]
35+
user "rails"
36+
working_directory rails_directory
37+
exec_start "#{node[:ruby][:bundle]} exec rails db:expire_tokens"
38+
sandbox :enable_network => true
39+
memory_deny_write_execute false
40+
read_write_paths "/var/log/web"
41+
end
42+
43+
systemd_timer "rails-cleanup" do
44+
description "Rails cleanup"
45+
on_calendar "02:00"
46+
end
47+
48+
service "rails-cleanup.timer" do
49+
action [:enable, :start]
3150
end

cookbooks/web/templates/default/cleanup.cron.erb

-3
This file was deleted.

0 commit comments

Comments
 (0)