
11

assets本地编译优化部署时间
source link: http://blog.grayson.org.cn/blog/2014/06/22/assetsben-di-bian-yi-you-hua-bu-shu-shi-jian
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

assets本地编译优化部署时间
Jun 22, 2014
随着rails项目js效果增加,加了JS MVC框架等,变的每发布一次时间越来越延长!也增加服务器在高峰时候cpu与内存的负担!
综合考虑解决把 rake assets:precompile 放在本地编译,然后通过capistrano2发布到服务端!
修改 config/deploy.rb
namespace :prepare do
desc "Compress assets in a local file"
task :compress_assets do
run_locally("rm -rf public/assets/*")
run_locally("bundle exec rake assets:precompile")
run_locally("touch assets.tgz && rm assets.tgz")
run_locally("tar zcvf assets.tgz public/assets/")
run_locally("mv assets.tgz public/assets/")
end
desc "Upload assets"
task :upload_assets do
upload("public/assets/assets.tgz", release_path + '/assets.tgz')
run "cd #{release_path}; tar zxvf assets.tgz; rm assets.tgz"
end
end
before "deploy:update_code", "prepare:compress_assets"
...
after "deploy:symlink", "prepare:upload_assets"
#####更新补充:
发现这个capistrano-local-precompile gem可以本地compile再同步到server上!
此文章 短链接: http://dlj.bz/Nh0jFA
Posted by grayson Jun 22, 2014 rails assets ruby capistrano deploy
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK