Rails Capistrano 部署错误

14

我已经安装了 gem capistrano 的 Capistrano。

在我的应用目录中,我安装了 cap install

此命令包括 deploy/production.rbdeploy/staging.rb,以及 config/deploy.rb

我的 production.rb 文件如下所示:

set :stage, :production
role :all, %w{seting@mydomain.com}
server 'sub.mydomain.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
set :ssh_options, { :forward_agent => true, :port => 1754, :keys => %w(/home/seting/.ssh/id_rsa) }

这是我的 deploy.rb 文件。

set :application, 'admin'
set :repo_url, 'git@bitbucket.org:username/myadmin.git'
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

最后,当我运行 cap production deploy 时,出现了错误。

错误信息如下:

cap aborted!
seting
/home/seting/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
/home/seting/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:156:in `ssh'
/home/seting/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:68:in `upload!'
/home/seting/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-3.0.0/lib/capistrano/tasks/git.rake:11:in `block (3 levels) in <top (required)>'
/home/seting/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `instance_exec'
/home/seting/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:42:in `run'
/home/seting/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.0.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
(See full trace by running task with --trace)

编辑 - 1

此外,在我的服务器上并没有进行任何特殊安装来运行Rails应用程序。我已决定先将我的文件移动到服务器上。这样做是正确的吗?


你运行过 cap production deploy:setup 吗?这样做是否有效或者会给你同样的错误? - CDub
出现错误:不知道如何构建任务'deploy:setup' - Prabhakaran
我是否需要在我的服务器或Git中配置其他内容? - Prabhakaran
1个回答

12

你应该设置角色名称为deploy而不是seting,或者其他方式。

set :stage, :production
set :branch, 'master'
set :deploy_to, '/srv/www/server.com/'
role :all, %w{deploy@server.com}
server 'server.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
fetch(:default_env).merge!(rails_env: :production)

这里是指南

你可能想要运行

cap production deploy:check

检查您的配置。

另外,在Capistrano 3.0中没有deploy:setup命令。


2
非常好的观点。我错过了他在使用3.0版本。很棒的发现。 - CDub
1
我尝试了你给的链接,但是仍然遇到同样的问题。你能帮我吗? - Prabhakaran
服务器的设置是如何完成的?手动完成吗?没有任务需要为所需的文件夹结构创建mkdir吗? - Arnold Roa

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接