2015-01-26 2 views
1

capistrano3를 사용하여 레일 앱을 배포합니다.capistrano3 : 'deploy : create_db'작업을 빌드하는 방법을 모름

namespace :deploy do 
    after "deploy", "deploy:create_db" 
    after "deploy", "deploy:migrate" 
    after "finishing", "deploy:restart" 

    task :restart do 
    on roles(:web) do 
     execute "mkdir -p #{current_path}/tmp" 
     execute "touch #{current_path}/tmp/restart.txt" 
    end 
    end 

    task :create_db do 
    on roles(:web) do 
     execute "cd #{current_path}; bundle exec rake db:create RAILS_ENV=#{rails_env}" 
    end 
    end 

end 

내가 cap -T 실행

가, 오류가 아래와 같이 발생 deploy.rb : 사전에

(Backtrace restricted to imported tasks) 
cap aborted! 
Don't know how to build task 'deploy:create_db' 

(See full trace by running task with --trace) 

cap -T --trace

** Invoke load:defaults (first_time) 
** Execute load:defaults 
cap aborted! 
Don't know how to build task 'deploy:create_db' 
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task_manager.rb:62:in `[]' 
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:353:in `[]' 
/Library/Ruby/Gems/2.0.0/gems/capistrano-3.3.5/lib/capistrano/dsl/task_enhancements.rb:12:in `after' 
/Users/liuxingqi/Public/Spar/config/deploy.rb:53:in `block in <top (required)>' 

희망 누군가가 나를 도울 수, 감사합니다! !! !!

+0

는 카피 스트라 노에는 작업 CREATE_DB라고 없다. 이것은 당신이 직접 쓰는 것이 필요합니다. –

+0

deploy.rb로 작성했습니다. – pangpang

+0

죄송합니다. 배포 네임 스페이스에 확실히 있습니까? –

답변

3

나는

이 시도 ... 처음 작업을 정의해야한다고 생각 :

namespace :deploy do 

    task :restart do 
    on roles(:web) do 
     execute "mkdir -p #{current_path}/tmp" 
     execute "touch #{current_path}/tmp/restart.txt" 
    end 
    end 

    task :create_db do 
    on roles(:web) do 
     execute "cd #{current_path}; bundle exec rake db:create RAILS_ENV=#{rails_env}" 
    end 
    end 

    after "deploy", "deploy:create_db" 
    after "deploy", "deploy:migrate" 
    after "finishing", "deploy:restart" 
end