我使用capistrano3来部署我的rails应用程序。
deploy.rb
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
时,错误发生如下:
(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 :(得分: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