gpt4 book ai didi

ruby-on-rails-3 - 部署时使用 capistrano 3 时遇到问题

转载 作者:太空狗 更新时间:2023-10-29 13:47:14 25 4
gpt4 key购买 nike

我在部署时遇到了使用 capistrano 3 的问题。我的应用程序默认运行到/tmp 目录,即使我提到了部署路径 (deploy_to)。运行 cap 使用的 git-ssh 脚本时出现一些权限被拒绝的错误。

$ 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"

我的问题是

1.为什么会生成tmp/myapp?我已经在 deploy_to 中提到了路径。如何克服这个?

2.如何避免生成git-ssh.sh文件。如上所述,它有一些密码问题。我怎样才能克服所有问题以进行正确部署。

在此先感谢您的帮助

最佳答案

  1. /tmp/myapp 实际上并不是应用程序运行的地方。它是创建该文件夹并检查它是否具有正确权限的 git:wrapper 任务的一部分。部署后,它将输出到您指定的正确文件夹“/home/ec2-user/capistrano-3/myapp”

  2. 请附上错误日志,以便更好地了解那里发生了什么。 deploy:check 在“退出状态 0(成功)”上方成功。

您可以使用 :tmp_dir 更改 tmp 目录引用:https://github.com/capistrano/capistrano/blob/master/README.md#configuration

关于ruby-on-rails-3 - 部署时使用 capistrano 3 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20967346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com