lavmeiker / capistrano-wpcli

Provides command line tools to facilitate Wordpress deploy.
MIT License
117 stars 34 forks source link

How to specify other port than 22 for wpcli:uploads:rsync:pull? #28

Closed cibulka closed 9 years ago

cibulka commented 9 years ago

Hello again!

making this gem work is a little challenging for me, as I use shared hosting with some extra security layers. Here's my first issue:

| => bundle exec cap production wpcli:uploads:rsync:pull
INFO[f43ef1a7] Running /usr/bin/env rsync -avz --rsh=ssh web720@81.91.83.149:/www/itvar.cz/wwwroot/www/shared/web/app/uploads/ web/app/uploads/ on localhost
cap aborted!
SSHKit::Command::Failed: rsync exit status: 65280
rsync stdout: Nothing written
rsync stderr: ssh: connect to host 81.91.83.149 port 22: Operation timed out
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [receiver=2.6.9]
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:56:in `block in _execute'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:37:in `tap'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:37:in `_execute'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:26:in `execute'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:34:in `block (6 levels) in <top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:14:in `instance_exec'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/backends/local.rb:14:in `run'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/sshkit-1.5.1/lib/sshkit/dsl.rb:10:in `run_locally'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:33:in `block (5 levels) in <top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:32:in `each'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bundler/gems/capistrano-wpcli-463d5e0418ba/lib/capistrano/tasks/wpuploads.rake:32:in `block (4 levels) in <top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bin/cap:23:in `load'
/Users/Cibulka/.rvm/gems/ruby-2.1.2/bin/cap:23:in `<main>'
Tasks: TOP => wpcli:uploads:rsync:pull
(See full trace by running task with --trace)

I assume that this error is pops up because my host requires port 2222 for SSH connections. I have this specified inside my deploy.rb config file like this -

set :ssh_options, {
    keys: ['~/.ssh/id_rsa'],
    port: 2222
}
jeremyzahner commented 9 years ago

This issue already popped of here: https://github.com/lavmeiker/capistrano-wpcli/issues/14.

set :wpcli_rsync_options, '-avz -e "ssh -p <port number>"' in your deploy/(env).rb file

I will make sure that we get something like this into the documentation.

jeremyzahner commented 9 years ago

Closing as duplicate of https://github.com/lavmeiker/capistrano-wpcli/issues/14.

cibulka commented 9 years ago

My bad, thanks! Quick question though: When I tried to update this gem to its latest version (meeting the LUX milestone?) by running bundle update, I keep getting version 0.0.9. Any idea what I might be doing wrong?

Here's what I've tried to add to my gemfile:

gem 'capistrano-wpcli'
gem 'capistrano-wpcli', "~> 0.1.1" # => Could not find gem 'capistrano-wpcli (~> 0.1.1) ruby' in the gems available on this machine.
gem 'capistrano-wpcli', :git => 'https://github.com/davestevens/capistrano-wpcli'
jeremyzahner commented 9 years ago

Hi @cibulka!

Rsync ports are integrated now by the way. =)

The problem right now is that @lavmeiker somehow is not responding and i am currently not allowed to push a new version of the gem. I will again try to reach him so he can publish the new versions.

gem 'capistrano-wpcli', :git => 'git@github.com:lavmeiker/capistrano-wpcli.git'

Like this you should get the newest version.

cibulka commented 9 years ago

You answer quickly!

Here's what has worked for me:

gem 'capistrano-wpcli', :git => 'https://github.com/lavmeiker/capistrano-wpcli.git'

git@github.com:lavmeiker/capistrano-wpcli.git threw error Could not read from remote repository for some reason.

Thank you!

cibulka commented 9 years ago

Weirdly enough, the problem persists even with capistrano-wpcli 0.1.1.

Using capistrano-wpcli 0.1.1 from https://github.com/lavmeiker/capistrano-wpcli.git (at master)

Here's the output:

INFO [41771153] Running /usr/bin/env rsync -avz --rsh=ssh web720@81.91.83.149:/www/itvar.cz/wwwroot/www/shared/web/app/uploads/ web/app/uploads/ as Cibulka@localhost
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Command::Failed: rsync exit status: 65280
rsync stdout: Nothing written
rsync stderr: ssh: connect to host 81.91.83.149 port 22: Operation timed out
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [receiver=2.6.9]

Tasks: TOP => wpcli:uploads:rsync:pull
(See full trace by running task with --trace)

I have this in my configuration (deploy.rb, environments/staging.rb, environments/production.rb to be safe):

set :wpcli_rsync_port, 2222

What am I doing wrong? Thanks again!

jeremyzahner commented 9 years ago

Ill have a look right away.

jeremyzahner commented 9 years ago

Opened new issue for this here: https://github.com/lavmeiker/capistrano-wpcli/issues/30

jeremyzahner commented 9 years ago

It works now. =)

See the updated documentation.

cibulka commented 8 years ago

Sorry, but it does not for me. :(

| => bundle exec cap production wpcli:uploads:rsync:pull
INFO [29d88580] Running /usr/bin/env rsync -avz --rsh=ssh --progress web720@81.91.83.149:/www/itvar.cz/wwwroot/www/shared/web/app/uploads/ web/app/uploads/ as Cibulka@localhost
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Command::Failed: rsync exit status: 65280
rsync stdout: Nothing written
rsync stderr: ssh: connect to host 81.91.83.149 port 22: Operation timed out
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-45/rsync/io.c(453) [receiver=2.6.9]

Tasks: TOP => wpcli:uploads:rsync:pull
(See full trace by running task with --trace)

My deploy/production.rb file:

set :stage, :production

# Simple Role Syntax
# ==================
#role :app, %w{deploy@example.com}
#role :web, %w{deploy@example.com}
#role :db,  %w{deploy@example.com}

# Extended Server Syntax
# ======================
server '81.91.83.149', user: 'web720', roles: %w{web app db}

set :ssh_options, {
    keys: ['~/.ssh/id_rsa'],
    port: 2222
}

set :tmp_dir, '/home/web720/capistrano-tmp'
set :deploy_to, -> { "/www/itvar.cz/wwwroot/www" }

SSHKit.config.command_map[:composer] = "/home/web720/composer.phar"
SSHKit.config.command_map[:wp] = "/home/web720/wp-cli.phar"

set :default_env, {
  path: [
    "/home/web720",
    "$PATH"
    ].join(":")
}

set :wpcli_remote_url, '//itvar.cz'
set :wpcli_local_url, '//itvar.dev'

fetch(:default_env).merge!(wp_env: :production)

My gemfile (relevant parts):

source 'https://rubygems.org'
gem 'capistrano'
gem 'capistrano-composer'
gem 'colorize'
gem 'capistrano-upload-config'
gem 'capistrano-env-config'
gem 'capistrano-wpcli', :git => 'https://github.com/lavmeiker/capistrano-wpcli.git'

Any ideas? Thanks!