Run statistics and cleanup scripts with right ruby version
authorTom Hughes <tom@compton.nu>
Tue, 8 Dec 2015 09:09:21 +0000 (09:09 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 8 Dec 2015 09:09:21 +0000 (09:09 +0000)
cookbooks/web/recipes/cleanup.rb
cookbooks/web/recipes/statistics.rb
cookbooks/web/templates/default/cleanup.cron.erb
cookbooks/web/templates/default/statistics.erb

index 8b8faca43f1bcb4ac3cdea3d9021b39ba6f0525c..2b1039020f1ae0532a8a3a8ccc9703ff732f1f38 100644 (file)
 
 include_recipe "web::base"
 
+ruby = "ruby#{node[:passenger][:ruby_version]}"
+rails_directory = "#{node[:web][:base_directory]}/rails"
+
 template "/etc/cron.daily/web-cleanup" do
   source "cleanup.cron.erb"
   owner "root"
   group "root"
   mode 0755
+  variables :ruby => ruby, :directory => rails_directory
 end
index c7bf9e81a5d5d85b0a1e08d2536581dc6ad9ec96..1be580c1e42b2047358ffecd85360441de02e841 100644 (file)
@@ -19,6 +19,7 @@
 
 include_recipe "web::base"
 
+ruby = "ruby#{node[:passenger][:ruby_version]}"
 rails_directory = "#{node[:web][:base_directory]}/rails"
 
 template "/usr/local/bin/statistics" do
@@ -26,7 +27,7 @@ template "/usr/local/bin/statistics" do
   owner "root"
   group "root"
   mode 0755
-  variables :directory => rails_directory
+  variables :ruby => ruby, :directory => rails_directory
 end
 
 template "/etc/cron.d/statistics" do
index 996aeec9ac7f3eb3828c4349acfc2429b1ba00e4..390b5bcc49c72cc72867bb0f03b1579b179196bf 100644 (file)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-<%= node[:web][:base_directory] %>/rails/script/cleanup
+<%= @ruby %> <%= @directory %>/script/cleanup
index 87386a23d6d5e040572209aa001c5f49bb295459..ccfe956cc3fa958a72d2b4a68604d9e0ac7088d8 100644 (file)
@@ -4,7 +4,7 @@
 export PATH=$PATH:/usr/local/bin
 
 # Generate new statistics
-<%= @directory %>/script/statistics > <%= @directory %>/tmp/data_stats.html
+<%= @ruby %> <%= @directory %>/script/statistics > <%= @directory %>/tmp/data_stats.html
 
 # Move new statistics into place
 mv -f <%= @directory %>/tmp/data_stats.html /store/rails/stats