Question

i am deploying with capistrano and I am strugg;ling to find out why it will not run migrations when I try to deploy the site.

here is the whole error:

 WARN [SKIPPING] No Matching Host for /usr/bin/env if test ! -d /home/deploy/forge_staging/releases/20140319132005; then echo "Directory does not exist '/home/deploy/forge_staging/releases/20140319132005'" 1>&2; false; fi
 WARN [SKIPPING] No Matching Host for bundle exec rake db:migrate

heres my setup:

deploy.rb

lock '3.1.0'
server "xxx.xxx.xxx.xxx"

set :application, "ForgeAndCo"
set :scm, "git"
set :repo_url, "my-repo"
# set :scm_passphrase, ""

set :user, "deploy"
set :use_sudo, false

set :ssh_options, {
  forward_agent: true,
  port: 14439
}

# files we want symlinking to specific entries in shared.
set :linked_files, %w{config/database.yml}

# dirs we want symlinking to shared
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

SSHKit.config.command_map[:rake]  = "bundle exec rake" #8
SSHKit.config.command_map[:rails] = "bundle exec rails"

set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master"


set :keep_releases, 20

namespace :deploy do
  desc 'Restart passenger without service interruption (keep requests in a queue while restarting)'
  task :restart do
    on roles(:app) do
      execute :touch, release_path.join('tmp/restart.txt')

      unless execute :curl, '-s -k --location localhost | grep "Forge" > /dev/null'
        exit 1
      end
    end
  end
  after :finishing, "deploy:cleanup"
end
# start new deploy.rb stuff for the beanstalk repo

staging.rb

role :app, %w{deploy@xxx.xxx.xxx.xxx}
role :web, %w{deploy@xxx.xxx.xxx.xxx}
role :db,  %w{deploy@xxx.xxx.xxx.xxx}

# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.
# server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value

set :stage, :staging

server "xxx.xxx.xxx.xxx", user: "deploy", roles: %w{web app db}
set :deploy_to, "/home/deploy/forge_staging"

set :rails_env, 'staging'                  # If the environment differs from the stage name
set :migration_role, 'migrator'            # Defaults to 'db'

set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master"

Is this an issue with roles?

Was it helpful?

Solution

remove from deploy.rb: (add capistrano-bundler and require it in the Capfile)

server "xxx.xxx.xxx.xxx"
SSHKit.config.command_map[:rake]  = "bundle exec rake"
SSHKit.config.command_map[:rails] = "bundle exec rails"
set :user, "deploy"   # you have it in staging.rb
set :use_sudo, false  # not used in cap3

remove from staging.rb:

role :app, %w{deploy@xxx.xxx.xxx.xxx}
role :web, %w{deploy@xxx.xxx.xxx.xxx}
role :db,  %w{deploy@xxx.xxx.xxx.xxx}
set :migration_role, 'migrator'            # <= this is why you got the error

PS: edit your question and replace the ip with xxx.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top