我以前设置过这个,但现在不能让它工作。我想要一个开发和生产网站。当我执行cap deploy时,它将设置一个“当前”符号链接(不确定我是如何做到的,因为在很长一段时间内,它甚至都不会这样做)。但是,如何让它为dev/prod部署和设置必要的symlink呢?
我的deploy.rb文件:
#require 'bundler/capistrano'
require 'capistrano/ext/multistage'
require 'capistrano_colors'
set :stages, %w(development production)
set :default_stage, 'development'
set :application, "myapp"
set :repository, "***"
# Target directory on the server
set :deploy_to, "/var/www/#{application}"
set :scm, :git
set :deploy_via, :remote_cache
set :user, '***'
set :use_sudo, false
role :web, "68.225.130.30" # Your HTTP server, Apache/etc
role :app, "68.225.130.30" # This may be the same as your `Web` server
role :db, "68.225.130.30", :primary => true # This is where Rails migrations will run
# List of symlinks to be generated. Keys are subdirectories of release_path.
SYMLINKS = { :config => ['database.yml'],
:public => ['system'] }
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')}"
# Not working =/
#run "touch /var/www/#{current_path}/tmp/restart.txt"
end
desc "Set up application symlinks."
task :app_symlinks do
SYMLINKS.keys.each do |key|
dir = key.to_s
SYMLINKS[key].each do |path|
run "ln -nfs #{shared_path}/#{dir}/#{path} #{release_path}/#{dir}/#{path}"
end
end
end
end我的deploy/development.rb文件:
set :deploy_to, "/var/www/#{application}"
set :branch, "master"
unset :rails_env
set :rails_env, "development"更新/回答:
问题出在current_path变量上。很奇怪,因为我试着用
设置:current_path,“开发”
和
设置应用程序,“#{ :current_path }/development”
但它并没有起作用。看起来我必须设置整个路径,这似乎很奇怪,因为我以前使用过后者。
set :current_path, "/var/www/#{application}/development"有人知道为什么吗?
发布于 2012-04-14 05:59:46
:current_path由capistrano基于:deploy_to路径+应用程序名称设置。您只能在命名空间任务中使用:current_path。
换句话说,它是一个方便的变量,用于创建符号链接、重新启动服务器和其他任务。
https://stackoverflow.com/questions/10148546
复制相似问题