2012-04-13 34 views
0

我已经设置过,但现在无法使用它。我想要一个开发和生产网站。当我做帽子部署时,它会设置一个“当前”符号链接(不知道我是如何做到这一点,因为很长一段时间它不会这样做)。但是,如何获得它来部署和设置dev/prod所需的符号链接?Capistrano多阶段 - 不创建开发/产品符号链接(仅限'当前')

我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 

我的部署/ development.rb文件:

set :deploy_to, "/var/www/#{application}" 
set :branch, "master" 
unset :rails_env 
set :rails_env, "development" 

UPDATE /回答:

问题是与变量的current_path。奇怪,因为我一直在使用

集尝试:的current_path, “发展”

集:的current_path, “#{}应用程序/开发”

,并没有奏效。看起来我必须设置整个路径,这看起来很奇怪,因为我之前使用过后者。

set :current_path, "/var/www/#{application}/development" 

任何人都知道为什么?

回答

0

:current_path由capistrano基于:deploy_to路径+:应用程序名称设置。您只能在名称空间任务中使用:current_path。

换句话说,这是一个方便的变量,用于创建符号链接,重新启动服务器和其他任务。

相关问题