简体   繁体   English

Capistrano +载波问题

[英]Capistrano + Carrierwave issue

I have an issue with Carrierwave and Capistrano. 我对Carrierwave和Capistrano有问题。 The situation is: 情况是:

  • I have set Capistrano to keep only one release. 我设置Capistrano仅保留一个版本。 (testing proposals). (测试建议)。
  • The current release is pointing to 20140918231215. 当前版本指向20140918231215。
  • Capistrano has the option: Capistrano可以选择:

    set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets tmp/sessions public/uploads} 设置:linked_dirs,%w {bin log tmp / pids tmp / cache tmp / sockets tmp / sessions public / uploads}

So, current public/uploads is linked to shared/public/uploads, that's ok. 因此,当前的公共/上传链接到共享/公共/上传,没关系。 The issue appears when I upload a new file. 当我上载新文件时出现此问题。 In this case a new folder is created in before release's folder. 在这种情况下,将在发行版之前的文件夹中创建一个新文件夹。

Is there any way to refresh Capistrano Uploader store_dir, I suspect that is taking a bad configuration. 有什么方法可以刷新Capistrano Uploader store_dir,我怀疑配置是否正确。

Notes: 笔记:

  • The new symlink from last_release to shared is correctly created. 正确创建了从last_release到shared的新符号链接。
  • The before release is deleted correctly. 之前的版本已正确删除。
  • The problem is that when I upload the new image, it is created in before_release/public/uploads. 问题是,当我上传新图像时,它是在before_release / public / uploads中创建的。 That folder doesn't exist, so It is created without symlink, obviously. 该文件夹不存在,因此显然创建时没有符号链接。

I really appreciate any help you can provide. 我非常感谢您可以提供的任何帮助。

If the folder in your server is properly symlinked, then capistrano is doing its work properly. 如果服务器中的文件夹正确链接,则capistrano正常工作。

Your problem sounds for me that your uploader is doing the wrong thing. 您的问题对我来说听起来像您的上传者做错了事。

Check the store_dir method, may be is doing something crazy: Mine looks like this: 检查store_dir方法,可能是在做疯狂的事情:我的看起来像这样:

class LogoUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick
  storage :file

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
end

Take into account that carrierwave already uses by default the public folder. 考虑到默认情况下,carrierwave已经使用了公用文件夹。

I have achieve to write to the new folder (last release) by means of doing "sudo service nginx restart" after deploy, what I thought was unnecessary, it is? 通过部署后执行“ sudo服务nginx重新启动”,我已经达到了写入新文件夹(最新发行版)的目的,我认为这是不必要的,是吗?

EDIT: 编辑:

I got it! 我知道了! I have added that line to config/deploy.rb: 我已经将该行添加到config / deploy.rb中:

namespace :deploy do
  desc "Restart"
  task :restart do
    on roles(:web) do
      execute "touch #{release_path}/tmp/restart.txt"
    end
  end
end

I've also added the file restart.txt to tmp folder. 我还已将文件restart.txt添加到tmp文件夹。

It seems the "trick" to restart Ruby on Rails via Phusion Passenger. 通过Phusion Passenger重新启动Ruby on Rails似乎是“技巧”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM