I am deploying my rails 3.2.14 application to 2 different servers with a load balancer in front of them. The assets are currently being precompiled on the server (via capistrano deployment).
For some reason the fingerprint on the application.js file is different between the two servers. The source file is identical. IF I remove the //= require_tree .
from the application.js then they both magically have the same fingerprint.
I've come across a few posts that mention this issue, but never really address the root cause:
I'm trying to avoid pre-compiling the assets locally as a way to solve this issue (at least for now...).
I was unable to easily work around this issue (i.e. did not want to fully spell out the assets tree in my application.js), so I ended up overriding the deploy:assets
task to compile assets locally and push to each server in my cluster.
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and scp to server'
task :precompile, :roles => :web, :except => { :no_release => true } do
if releases.length <= 1 || capture("cd #{latest_release} && #{source.local.log(source.next_revision(current_revision))} vendor/assets/ app/assets/ | wc -l").to_i > 0
run_locally "bundle exec rake assets:precompile"
run_locally "cd public; tar -zcvf assets.tar.gz assets"
top.upload "public/assets.tar.gz", "#{shared_path}", :via => :scp
run "cd #{shared_path}; tar -zxvf assets.tar.gz"
run_locally "rm public/assets.tar.gz"
run_locally "bundle exec rake assets:clean"
else
logger.info 'Skipping asset pre-compilation because there were no asset changes'
end
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With