lib/softwear/lib.rb in softwear-lib-1.1.0 vs lib/softwear/lib.rb in softwear-lib-1.2.0

- old
+ new

@@ -60,10 +60,12 @@ end ) def self.capistrano(context) context.instance_eval do + Rake::Task["deploy:compile_assets"].clear + ruby = fetch(:rvm_ruby_string) || fetch(:rvm_ruby_version) gem_home_1 = fetch(:gems_path) || "~/.rvm/rubies/#{ruby}/gems" gem_home_2 = "~/.rvm/gems/#{ruby}" namespace :deploy do @@ -81,13 +83,57 @@ execute :mkdir, '-p', "#{release_path}/tmp" execute :touch, release_path.join('tmp/restart.txt') end end + after :publishing, :restart_sidekiq_manager do + on roles(:sidekiq) do + execute 'sudo restart sidekiq-manager' + end + end + # This is no longer necessary # before :updating, :update_softwear_lib - after :publishing, :restart + + desc 'Compile assets' + task :compile_assets => [:set_rails_env] do + invoke 'deploy:assets:precompile_local' + invoke 'deploy:assets:backup_manifest' + end + + namespace :assets do + + desc "Precompile assets locally and then rsync to web servers" + task :precompile_local do + # compile assets locally + run_locally do + execute "RAILS_ENV=#{fetch(:stage)} bundle exec rake assets:precompile" + end + + # rsync to each server + assets_dir = "public/#{fetch(:assets_prefix) || 'assets'}" + local_dir = "./#{assets_dir}/" + on roles( fetch(:assets_roles, [:web]) ) do + # this needs to be done outside run_locally in order for host to exist + remote_dir = "#{host.user}@#{host.hostname}:#{release_path}/#{assets_dir}" + + execute "mkdir -p #{release_path}/#{assets_dir}" + run_locally { execute "rsync -av --delete #{local_dir} #{remote_dir}" } + + if fetch(:asset_sync) + with rails_env: fetch(:rails_env) || fetch(:stage) do + within(release_path) do + with_rvm(fetch(:task_ruby_version)) { execute :rake, 'assets:sync' } + end + end + end + end + + # clean up + run_locally { execute "rm -rf #{local_dir}" } + end + end end end def self.fix_sort_argument_error_on_rubinius