English 中文(简体)
如何让Capistrano不再失败?
原标题:How can I get Capistrano to stop failing at deploy:create_symlink?

至少这样看起来像山地运动失败了。 它让整个部署过程 和最后。这里是产出。

* executing `deploy:create_symlink 
* executing "rm -f ~/xxx.xx.xx/test/current && ln -s ~/xxx.xx.xx/test/releases/20120525193307 ~/xxx.xx.xx/test/current"
servers: ["test.xxx.xx.xx"]
["test.xxx.xx.xx"] executing command
 ** [out :: test.xxx.xx.xx] rm: cannot remove `/var/www/vhosts/xxx.xx.xx/test/current : I command finished in 460ms
*** [deploy:create_symlink] rolling back
*** no previous release to rollback to, rollback of symlink skipped
* executing "rm -rf /var/www/vhosts/xxx.xx.xx/test/releases/20120525195909; true"
servers: ["test.xxx.xx.xx"]
[test.xxx.xx.xx] executing command
command finished in 524ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell  default  -c  rm -f /var/www/vhosts/xxx.xx.xx/test/current && ln -s /var/www/vhosts/xxx.xx.xx/test/releases/20120525195909 /var/www/vhosts/xxx.xx.xx/test/current " on xxx.xx.xx

the app is using capistrano (2.12.0) capistrano-ext (1.2.1) obviously there are more gems just trying to put what seems relevant, please let me know if more info would be helpful.

这里是部署.rb

require "rvm/capistrano"
require  bundler/capistrano 
require  capistrano/ext/multistage 

set :stages, %w(staging production)
set :default_stage,  staging 

set :application,  xxx 

# trying to not use sudo on the deployment
#set :use_sudo, false

#set :copy_exclude, [".git", "spec"]

set :repository,   ~/git/xxx.git 
set :local_repository, "~/rorwork/xxx/.git"
set :scm, :git
set :user,  xxx 
set :group,  xxxx 
ssh_options[:forward_agent] = true
set :branch,  master 
set :deploy_via, :remote_cache
set :scm_command, "/usr/local/bin/git"
set :local_scm_command, :default
default_run_options[:pty] = true
set :normalize_asset_timestamps, false #for asset piple

set :dbuser,  xxx 
set :dbpass,  xxx 

# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"

# if you re still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
 namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path, tmp , restart.txt )}"
   end
 end

和阵列,rb

set :domain,  test.xxx.xx.xx 

role :web, domain                          # Your HTTP server, Apache/etc
role :app, domain                          # This may be the same as your `Web` server
role :db,  domain, :primary => true        # This is where Rails migrations will run

set :deploy_to, "/var/www/vhosts/xxx.xx.xx/test"
set :rails_env,  staging 
set :rack_env, rails_env

set :dbname, "xxx_staging"

#set :bundle_without, [:test, :development, :production]

i 手动在部署目录中创建当前文件夹、 共享和发布文件夹, 并指派合适的用户: group 。 最初是获取 dirs 的许可问题, 但已经解决了 。 有点亏损, 许多寻找解决方案的工作还没有解决任何问题。 任何建议或经验都非常感激!

测试 cap 中继部署 部署 认为我也会尝试生产, cap 生产同时部署 保释... 一些关于一致性的聪明想法。

最佳回答

找到它了 找到它了

删除当前目录, 并让 Capistrano 创建当前与最新版本的同步链接 。

我会试着清理一下。 我实际上正在创建文件夹当前和这样的, mkdir 当前的文件夹。 这会妨碍 Capistrano 创建符号链接。 尝试它, 制造一个名为 bob 的文件夹, 然后在同一目录中制造一个叫做 bob 的符号链接, 并把它指向一个它可能会将符号链接 Bob 放在目录 Bob 中的地方 。

当我删除了当前共享的等、 目录、 Capistrano 可以创建当前和其他必要的符号链接。 因此, 具体地说, 删除当前目录可以允许当前目录创建当前符号链接, 仅指向发布目录下的最新部署 。

注 下错误,问题所在。

** [out :: test.xxx.xx.xx] rm: cannot remove `/var/www/vhosts/xxx.xx.xx/test/current : I command finished in 460ms

失败的原因。 我创建了名为当前文件夹 。 这是问题所在 。 它不应该是一个目录, 它应该是一个交错链接, 由 Capistrano 创建 。

通过创建它打破了部署的文件夹。 删除这些文件夹可以让 Capistrano 创建相同名称的符号链接。 自此以后, 光滑航行 。

问题回答

我刚找到一个类似的问题

这里的错误第一个错误 :

cap aborted! Errno::ECONNREFUSED: Connection refused - connect(2) for "{my-ip-address}" port {my-ssh-port}

我也会犯同样的错误:

Tasks: TOP => git:create_release (See full trace by running task with --trace) The deploy has failed with an error: #<Errno::ECONNREFUSED: Connection refused - connect(2) for "my-ip-address" port {my-port}>

在我服务器运行 Fail2Ban 时, 这与同时举行的SSH 会话是一个问题。 解决这个问题, 我只是做了以下事情:

包含 SSH 配置的监狱编辑

$ sudo nano /etc/fail2ban/jail.local

look for [SSH] and set enabled = false find [ssh-ddos] and set enabled = false

记住, 在您更改后重新启动 Fail2Ban 并打开 ssh (如果使用此功能)

$ sudo service fail2ban reload
$ sudo /etc/init.d/ssh reload

值得指出的是,在部署的不同步骤(任务)中,这种连接会被拒绝,例如,在重新启动和快速 bundule exec 上限生产部署后:检查 似乎一切都很好。然后,我试图部署和接收同样的错误,但在执行不同的任务时,我还使用UFW,我用UFW使UFW失效,没有问题地重新启用。UFW不是上述问题的原因。

在我解决了Capistrano将无法从当前目录到最新发布创建符号链接的问题之后。 错误如下:

Tasks: TOP => deploy:symlink:release The deploy has failed with an error: #<SSHKit::Command::Failed: rm exit status: 1 rm stdout: Nothing written rm stderr: Nothing written > ** Invoke deploy:failed (first_time) ** Execute deploy:failed

在广泛阅读后,我浏览了我的文档根,并列出了目录内容 ls -la 我注意到, current 目录不在部署用户组中,我删除了当前文件夹(sudo rm -rf current )和一切顺利。祝你好运。





相关问题
Is there a Perl or Lua alternative to Capistrano?

For a number of web-applications I need something like Capistrano to automate deployment. I know Capistrano can be used to deploy non-ruby applications but I m not familiar with Ruby, so I expect ...

Capistrano not restarting

Capistrano is deploying cold, deploying updates and uploading the symlink fine. It will not however restart. I notice that permission is denied on the /script/process/reaper file. I have found a ...

How to build task gems:install

I am deploying my rails app to a linux server and i have some of the rake tasks missing inlcuding rake gems:install and rake db I am running rails 2.3.4 from GEM. Why is this? How do I fix this? ...

Multiple webs on a server using capistrano

Is there any way to configure Capistrano for deploying many webs on a server? I would like to have a project on port 80 an other project on port 1000 and manage each one with different dbs.

Starting delayed_job at startup

I m using delayed_job with capistrano and would like a way to start delayed_job on startup of the web application using the script/delayed_job start . This way capistrano can restart it on deploy. ...

热门标签