0

我以前设置过,但现在无法正常工作。我想要一个开发和生产站点。当我进行 cap deploy 时,它会设置一个“当前”符号链接(不确定我是如何做到的,因为很长一段时间它甚至都不会这样做)。但是我如何让它为开发/产品部署和设置必要的符号链接?

我的 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, "#{application}/development"

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

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

有谁知道为什么?

4

1 回答 1

0

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

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

于 2012-04-13T21:59:46.477 回答