[英]Capistrano and Carrierwave
I'm deploying a Ruby on Rails and NodeJS application using Capistrano. 我正在使用Capistrano部署Ruby on Rails和NodeJS应用程序。 The uploads folder gets removed on every deploy. 每次部署都会删除上载文件夹。
This popped up on several places but it doesn't seem to work: 这在几个地方弹出,但似乎不起作用:
# Keep File Uploads
task :symlink_uploads do
run "ln -nfs #{shared_path}/rails/uploads #{release_path}/rails/public/uploads"
end
after 'deploy:update_code', 'deploy:symlink_uploads'
the repo: 回购:
repo:
/node
/rails
Thanks! 谢谢!
There is another solution to this problem. 这个问题还有另一种解决方案。 You can add your uploads
dir to Capistrano's shared_children
and it will do all the magic automatically. 您可以将uploads
目录添加到Capistrano的shared_children
,它将自动完成所有操作。 You can find more details in this answer: https://stackoverflow.com/a/9710542/835935 您可以在此答案中找到更多详细信息: https : //stackoverflow.com/a/9710542/835935
Make sure you remove the existing public/uploads folder, passing -f
to ln
doesn't cover removing target directories (or at least hasn't done so portably for me) 确保删除现有的public / uploads文件夹,将-f
传递给ln
并不涉及删除目标目录(或者至少对我而言不是可移植的)
My symlink directories tasks normally look like 我的symlink目录任务通常看起来像
task :symlink_uploads do
run "rm -rf #{release_path}/rails/public/uploads} && ln -nfs #{shared_path}/rails/uploads #{release_path}/rails/public/uploads"
end
Obviously make sure there is nothing in the checked in version of public/uploads that you need! 显然,请确保签入版本的public / upload中没有任何您需要的内容!
Did you try 你试过了吗
after 'deploy:update_code', ':symlink_uploads'
Your :symlink_uploads
task is not in a namespace, so rather do the above or put it in a namespace 您的:symlink_uploads
任务不在名称空间中,因此请执行上述操作或将其放在名称空间中
namespace :deploy do
task :symlink_uploads do
# ...
end
end
I have similar problem with uploaded file with my RoR app. 我的RoR应用程序上传的文件存在类似的问题。 This is my capistrano tasks: 这是我的capistrano任务:
...
task :link_public_folder, :roles => [:app, :web] do
run "mv -u #{release_path}/public/* #{shared_path}/public"
run "rm -rf #{release_path}/public"
run "ln -s #{shared_path}/public #{release_path}/public"
end
after "deploy:update", "deploy:link_public_folder"
task :setup_config, :roles => :app do
sudo "ln -nfs #{current_path}/config/apache.conf /etc/apache2/sites-available/#{application}"
run "mkdir -p #{shared_path}/config"
run "mkdir -p #{shared_path}/public"
put File.read("config/database.yml"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config"
...
Maybe help you 也许可以帮你
Edit: I use Carrierwave too. 编辑:我也使用载波。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.