2012-02-23 8 views
2

の予想外の終わり、私はこのトピックに@Cowardからの回答をたどっ:How do I run a rake task from Capistrano? に私のdeploy.rbにカスタマイズタスクrake:invokeを追加しますrakeタスクを遠隔から呼び出すことができます。実行リモートrakeタスク:-c:1行目:構文エラー:ファイル

それはそれ自身の一部で完璧に動作しますが、私は私のcap deploy処理を行っている次のエラーを取得するassets:precompile

[mydomain.com] rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell '[email protected]' -c 'cd /var/deploy/ziya/releases/20120223100338 && #<Capistrano::Configuration::Namespaces::Namespace:0x007ff2b4a4bad8> RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile' 
** [out :: my domain.com] bash: -c: line 1: syntax error: unexpected end of file 
    command finished in 1265ms 

それは注射何かのようなもののようだが、私はちょうどに間違って何が起こっているかを知ることができません私deploy.rb

deploy.rb:

$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path. 
require "rvm/capistrano"     # Load RVM's capistrano plugin. 
set :rvm_ruby_string, '[email protected]' 
set :use_sudo, true 

require "bundler/capistrano" 

set :stages, %w(staging production) 
set :default_stage, "production" 
require 'capistrano/ext/multistage' 

set :application, "my application" 

# ssh to the deploy server 
default_run_options[:pty] = true 

# setup scm: 
set :repository, "mygiturl" 
set :deploy_via, :remote_cache 
set :scm_username, "myusernmae" 
set :scm, :git 
set :scm_verbose, "true" 
set :branch, "master" 
ssh_options[:forward_agent] = true 

set(:releases_path)  { File.join(deploy_to, version_dir) } 
set(:shared_path)  { File.join(deploy_to, shared_dir) } 
set(:current_path)  { File.join(deploy_to, current_dir) } 
set(:release_path)  { File.join(releases_path, release_name) } 

set :deploy_to, "/var/deploy/#{application}" 

# If you are using Passenger mod_rails uncomment this: 
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')}" 
    end 

    task :bootstrap do 
    run "cd #{release_path}; rake bootstrap:all RAILS_ENV=#{rails_env}" 
    end 

    task :import_all do 
    run "cd #{release_path}; rake import:pages RAILS_ENV=#{rails_env}" 
    run "cd #{release_path}; rake import:legacy_all RAILS_ENV=#{rails_env}" 
    end 

    task :import_pages do 
    run "cd #{release_path}; rake import:pages RAILS_ENV=#{rails_env}" 
    end 
end 

namespace :rake do 
    desc "Run a task on a remote server." 
    # run like: cap staging rake:invoke task=a_certain_task 
    task :invoke do 
    run("cd #{deploy_to}/current; /usr/bin/env rake #{ENV['task']} RAILS_ENV=#{rails_env}") 
    end 
end 

富栄トン私はnamespace :deploytask :invokeを移動する場合、namespace :rakeをドロップするには、そのすべてが、それはとても混乱だ、大丈夫です...

+0

恐ろしい!私の命を救いました!ありがとうございました! =) – dimitarvp

答えて

2

これは、使用してすくいコマンドラインとして使用されるコマンドこのようyou can overrideで、そのソースdeclare rake as internal variableにカピストラーノ以来起こります展開ファイルにset :rake命令があります。

しかし、カピストラノの内部構造のために、rake名前空間を宣言すると、宣言されたレーキ変数が優先されます。したがって、capistranoが資産をプリコンパイルするためのレシピを実行し、builds the required command line"rake"文字列を返す代わりにrake変数が変数に宣言された名前空間を文字列に変換して返します。あなたは、構築されたコマンドラインのこの部分でそれを見ることができます。

... && #<Capistrano::Configuration::Namespaces::Namespace:0x007ff2b4a4bad8> RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile' 

これは明らかに、シェルの構文エラーが発生し、これは、名前空間を変更すると、あなたの問題を解決する理由の理由です。

関連する問題