Class: Photish::Plugin::Sshdeploy::Deploy
- Inherits:
-
Object
- Object
- Photish::Plugin::Sshdeploy::Deploy
- Defined in:
- lib/photish/plugin/sshdeploy/deploy.rb
Instance Method Summary collapse
- #deploy_site ⇒ Object
-
#initialize(config, log) ⇒ Deploy
constructor
A new instance of Deploy.
Constructor Details
#initialize(config, log) ⇒ Deploy
Returns a new instance of Deploy.
5 6 7 8 |
# File 'lib/photish/plugin/sshdeploy/deploy.rb', line 5 def initialize(config, log) @config = config @log = log end |
Instance Method Details
#deploy_site ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/photish/plugin/sshdeploy/deploy.rb', line 10 def deploy_site log.info "Publishing website to #{host}" log.info "Cleaning temp locations and ensuring directories exist" execute("ssh #{host} -v '" + "mkdir -p #{publish_temp_dir} && " + "rm -rf #{publish_temp_dir}/* && " + "mkdir -p #{upload_temp_dir} && " + "rm -rf #{upload_temp_dir}/*" + "'") log.info "Creating tar gz of photish site" execute("GZIP=-9 tar -zcvf " + "#{output_dir_compress_file} " + "-C #{output_dir_with_base} .") log.info "Uploading site to upload temp location" execute("rsync -v " + "-e 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' " + "--progress #{output_dir_compress_file} " + "#{host}:#{upload_temp_dir}") log.info "Extracting site to publish temp location" execute("ssh #{host} -v " + "'tar -zxvf " + "#{upload_temp_dir}/#{output_dir_compress_filename} " + "-C #{publish_temp_dir}'") log.info "Moving publish temp to publish folder" execute("ssh #{host} -v " + "'sudo su #{www_user} bash -c \"" + "mkdir -p #{publish_dir} && " + "rm -rf #{publish_dir}/* && " + "cp -rf #{publish_temp_dir}/* #{publish_dir}\"'") log.info "#{Time.new}: Deployment complete" ensure FileUtils.rm_rf(output_dir_compress_file) end |