【问题标题】:rails capistrano deployment errorrails capistrano 部署错误
【发布时间】:2013-10-11 17:38:53
【问题描述】:

我已经用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了吗?这是否有效或给您同样的错误?
  • 得到错误Don't know how to build task 'deploy:setup'
  • 我是否必须在我的服务器或 git 中配置任何其他东西

标签: ruby-on-rails ruby-on-rails-3 deployment capistrano


【解决方案1】:

您应该设置角色名称部署而不是设置或其他方式。

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)

这里是guide

你可能想跑

cap production deploy:check

检查您的配置。

capistrano 3.0 中也没有 deploy:setup

【讨论】:

  • 一个很好的观点。我错过了他使用的是3.0。很棒的收获。
  • 我尝试了您提供的上述链接,但遇到了同样的问题。你能帮帮我吗?
  • 服务器上的设置是如何完成的?手动?没有为所需文件夹结构执行 mkdir 的任务?
猜你喜欢
  • 2016-10-08
  • 1970-01-01
  • 2016-01-02
  • 1970-01-01
  • 1970-01-01
  • 2013-01-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多