Created
November 9, 2017 02:50
-
-
Save jcrisp/8d0441d1181cdeaff93245c00d65af84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :deploy_pdfs do | |
on roles(:app) do |h| | |
execute "mkdir -p #{remote_shared_pdfs_dir}" | |
rsync_pdfs("#{h.username}@#{h.hostname}") | |
end | |
end | |
task :delete_pdfs do | |
on roles(:app) do | |
execute "rm #{remote_shared_pdfs_dir}/*" | |
end | |
end | |
def rsync_pdfs(server) | |
rsync("#{local_pdfs_dir}/*", "#{server}:#{remote_shared_book_dir}") | |
end | |
def rsync(source, destination) | |
cmd = "rsync -aHxvzh --numeric-ids -e \"ssh -o Compression=no -x\" #{source} #{destination}" | |
puts cmd | |
raise "RSYNC FAILED!" unless system(cmd) | |
end | |
def remote_shared_pdfs_dir | |
fetch(:deploy_to) + "/shared/pdfs" | |
end | |
def local_pdfs_dir | |
"#{File.dirname(__FILE__)}/../pdfs" | |
end | |
def remote_release_dir | |
fetch(:deploy_to) + "/current" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment