我正在使用Capistrano 2.12.0运行Rails 3.2.x应用程序。我已经从github /版本控制中取出了我的database.yml,并在/home/deploy/myapp/shared/config/database.yml
下手动放置了一份副本
我试图让deploy.rb
使用before:assets:precompile
对此文件进行符号链接,以便在发布目录中对该文件进行符号链接,然后部署就可以继续。这是我得到的错误:
/Users/james/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/capistrano-2.12.0/lib/capistrano/configuration/callbacks.rb:103:in `on': please specify either a task name or a block to invoke (ArgumentError)
这是我的deploy.rb的样子:
deploy.rb
require "bundler/capistrano"
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
set :shared_children, shared_children + %w{public/uploads}
server "72.14.181.22", :web, :app, :db, primary: true
set :application, "myapp"
set :user, "deploy"
set :deploy_to, "/home/#{user}/#{application}"
#set :deploy_via, :remote_cache
set :use_sudo, false
set :rails_env, "production"
set :scm, "git"
set :repository, "git@github.com:james/#{application}.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
after "deploy:update"
before "deploy:assets:precompile", "config_symlink"
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
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{rails_env}"
end
end
task :config_symlink do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
基本上我需要做的是在资源预编译之前将/home/deploy/myapp/shared/config/database.yml符号链接到/home/deploy/myapp/current/config/database.yml,这样数据库就可以了访问。
我确定这里有一些语法错误但可以真正使用一些帮助。我希望保持database.yml
不受版本控制,直接将其保留在myapp / shared / config中,并在部署时将其符号链接以用于安全目的。
最长的时间我以为我一直这样做,但显然我没有这样做,所以我需要弄清楚这一点。
我非常感谢任何帮助,因为我不想在github /版本控制中使用database.yml
。
答案 0 :(得分:0)
我认为我有这个工作。它看起来像我原来的deploy.rb,我正在调用after "deploy:update"
,但没有传递任何东西到回调,所以它是轰炸我。我已经清理了我的deploy.rb文件并测试了部署到登台服务器,它似乎有效。
deploy.rb已更新
require "bundler/capistrano"
set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
set :shared_children, shared_children + %w{public/uploads}
server "72.14.181.11", :web, :app, :db, primary: true
set :application, "myapp"
set :user, "deploy"
set :deploy_to, "/home/#{user}/#{application}"
#set :deploy_via, :remote_cache
set :use_sudo, false
set :rails_env, "production"
set :scm, "git"
set :repository, "git@github.com:james/#{application}.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
before "deploy:assets:precompile", "config_symlink"
after "deploy", "deploy:cleanup" # keep only the last 5 releases
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
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; bundle exec rake db:seed RAILS_ENV=#{rails_env}"
end
end
task :config_symlink do
run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end