Ruby on rails 3 部署时使用capistrano 3时出现问题
部署时使用capistrano 3时遇到问题。默认情况下,我的应用程序运行到/tmp目录,即使我提到了部署路径(deploy_to)。运行cap使用的git ssh脚本时出现权限被拒绝错误 $cap开发部署:选中Ruby on rails 3 部署时使用capistrano 3时出现问题,ruby-on-rails-3,git,ssh,capistrano,capistrano3,Ruby On Rails 3,Git,Ssh,Capistrano,Capistrano3,部署时使用capistrano 3时遇到问题。默认情况下,我的应用程序运行到/tmp目录,即使我提到了部署路径(deploy_to)。运行cap使用的git ssh脚本时出现权限被拒绝错误 $cap开发部署:选中 INFO [8ad6d60d] Running mkdir -p /tmp/myapp/ on 40.12.255.11 INFO [8ad6d60d] Finished in 10.468 seconds with exit status 0 (successful). INF
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
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"
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 :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
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"
我的问题是
1.为什么生成tmp/myapp?我在deploy_to中提到了路径。如何克服这个问题
2.如何避免生成git-ssh.sh文件。如上所述,它存在一些密码问题。如何克服所有问题以进行适当的部署
提前感谢您的帮助此命令可解决capistrano3问题
cap-jefferson部署:设置
cap-jefferson部署:检查
capjefferson部署
重新启动系统
/tmp/myapp
实际上不是运行应用程序的位置。它是git:wrapper任务的一部分,该任务创建该文件夹并检查它是否具有正确的权限。一旦部署,它将输出到您指定的正确文件夹“/home/ec2 user/capistrano-3/myapp”:tmp\u dir
参考资料:要解决此问题,需要在
deploy.rb
文件中添加以下行:
set :tmp_dir, "/home/user/tmp"
如果我遇到同样的问题,你有没有找到解决问题的办法?@Martinffx-事实上这不是问题。它工作正常。见下面的答案。我在部署的最初时间发布了这个问题。读这个。你可以理解很多。