]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/web/resources/rails_port.rb
Merge remote-tracking branch 'github/pull/183'
[chef.git] / cookbooks / web / resources / rails_port.rb
index 8da12cc53790319cfe2b8bb05cb9e83f832b31c9..067c1334c2ef6a01dede62dd9e7db1bf4297022f 100644 (file)
@@ -125,9 +125,10 @@ action :create do
     user new_resource.user
     group new_resource.group
     notifies :run, "execute[#{rails_directory}/Gemfile]"
+    notifies :run, "execute[#{rails_directory}/app/assets/javascripts/i18n]"
     notifies :run, "execute[#{rails_directory}/public/assets]"
     notifies :delete, "file[#{rails_directory}/public/export/embed.html]"
-    notifies :run, "execute[#{rails_directory}]"
+    notifies :restart, "passenger_application[#{rails_directory}]"
   end
 
   declare_resource :directory, "#{rails_directory}/tmp" do
@@ -151,7 +152,7 @@ action :create do
               :name => new_resource.database_name,
               :username => new_resource.database_username,
               :password => new_resource.database_password
-    notifies :run, "execute[#{rails_directory}]"
+    notifies :restart, "passenger_application[#{rails_directory}]"
   end
 
   application_yml = edit_file "#{rails_directory}/config/example.application.yml" do |line|
@@ -306,7 +307,7 @@ action :create do
     group "root"
     environment "NOKOGIRI_USE_SYSTEM_LIBRARIES" => "yes"
     subscribes :run, "gem_package[bundler#{new_resource.ruby}]"
-    notifies :run, "execute[#{rails_directory}]"
+    notifies :restart, "passenger_application[#{rails_directory}]"
   end
 
   execute "#{rails_directory}/db/migrate" do
@@ -316,10 +317,20 @@ action :create do
     user new_resource.user
     group new_resource.group
     subscribes :run, "git[#{rails_directory}]"
-    notifies :run, "execute[#{rails_directory}]"
+    notifies :restart, "passenger_application[#{rails_directory}]"
     only_if { new_resource.run_migrations }
   end
 
+  execute "#{rails_directory}/app/assets/javascripts/i18n" do
+    action :nothing
+    command "bundle#{new_resource.ruby} exec rake i18n:js:export"
+    environment "RAILS_ENV" => "production"
+    cwd rails_directory
+    user new_resource.user
+    group new_resource.group
+    notifies :run, "execute[#{rails_directory}/public/assets]"
+  end
+
   execute "#{rails_directory}/public/assets" do
     action :nothing
     command "bundle#{new_resource.ruby} exec rake assets:precompile"
@@ -327,18 +338,14 @@ action :create do
     cwd rails_directory
     user new_resource.user
     group new_resource.group
-    notifies :run, "execute[#{rails_directory}]"
+    notifies :restart, "passenger_application[#{rails_directory}]"
   end
 
   file "#{rails_directory}/public/export/embed.html" do
     action :nothing
   end
 
-  execute rails_directory do
-    action :nothing
-    command "passenger-config restart-app --ignore-app-not-running --ignore-passenger-not-running #{rails_directory}"
-    user "root"
-    group "root"
+  passenger_application rails_directory do
     only_if { ::File.exist?("/usr/bin/passenger-config") }
   end
 
@@ -353,11 +360,8 @@ action :create do
 end
 
 action :restart do
-  execute rails_directory do
-    action :run
-    command "passenger-config restart-app --ignore-app-not-running --ignore-passenger-not-running #{rails_directory}"
-    user "root"
-    group "root"
+  passenger_application rails_directory do
+    action :restart
   end
 end