Pergunta

I'm having trouble using capistrano 3 while deploying. My app runs into /tmp directory by default even though I mentioned deployment path(deploy_to). There's some permission denied error running the git-ssh script that cap uses.

$ cap development deploy:check

 INFO [8ad6d60d] Running mkdir -p /tmp/myapp/ on 40.12.255.11
 INFO [8ad6d60d] Finished in 10.468 seconds with exit status 0 (successful).
 INFO Uploading /tmp/myapp/git-ssh.sh 100.0%
 INFO [b1e9863e] Running chmod +x /tmp/myapp/git-ssh.sh on 40.12.255.11
 INFO [b1e9863e] Finished in 8.093 seconds with exit status 0 (successful).

$ cat /tmp/myapp/git-ssh.sh

#!/bin/sh -e

exec /usr/bin/ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no "$@"

config/deploy.rb

set :application, "myapp"
set :scm, :git
set :repo_url,  "git@github.com:example/webapp.git"
set :deploy_to, "/home/ec2-user/capistrano-3/myapp"
set :ssh_options, {:keys => ["#{ENV['HOME']}/.ssh/myapp.pem"] }

set :log_level, :info
set :rvm_ruby_string, '2.0.0'
set :rvm_type, :user

set :branch, "master"
set :user, "ec2-user"
set :use_sudo, false
set :keep_releases, 2
set :git_shallow_clone, 1
set :deploy_via, :copy

set :whenever_command, "bundle exec whenever"
require 'sidekiq/capistrano'

namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :touch, release_path.join('tmp/restart.txt')
    end
  end
  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

  after :finishing, 'deploy:cleanup'

end

Capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'

Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

config/deploy/development.rb

set :deploy_to, "/home/ec2-user/capistrano-3/myapp"
set :rails_env, "development"
set :unicorn_env, "development"
server "ec2-user@40.12.255.11", user: "ec2-user", roles: %w{web app db}
set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master"

My questions are

1.why tmp/myapp is generated? I have mentioned the path in deploy_to. How to overcome this?

2.How to avoid git-ssh.sh file generated. It has some password issues as mentioned above. How can I overcome all the problem to have proper deployment.

Thanks in advance for any help

Foi útil?

Solução

  1. /tmp/myapp isn't actually where the app is being run. It is part of the git:wrapper task which creates that folder and checks that it has the correct permissions. Once you deploy it will output into the correct folder that you specified "/home/ec2-user/capistrano-3/myapp"

  2. Please attach the log of the errors to get a better idea of what is going on there. The deploy:check is successful above "with exit status 0 (successful)."

You can change the tmp directory using :tmp_dir Reference: https://github.com/capistrano/capistrano/blob/master/README.md#configuration

Outras dicas

to resolve this issue the line below needs to be added in the deploy.rb file:

set :tmp_dir, "/home/user/tmp"

This command resolves the capistrano3 issue

cap jefferson deploy:setup

cap jefferson deploy:check

cap jefferson deploy

reboot the system

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top