【发布时间】:2018-12-10 04:42:50
【问题描述】:
我正在尝试使用 capistrano 3 部署我的 rails 4 应用程序。我已经在 gemfile 中声明了所有要求并添加了 Capfile。我关注了this gist。
我当前的deploy.rb 文件看起来像:
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'my_app_name'
set :repo_url, 'git@github.com:.........'
set :user, 'username'
set :use_sudo, false
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :scm, :git
# set :deploy_via, :remote_cache # off while it is first deployment
set :deploy_via, :copy
# Default value for :format is :pretty
# set :format, :pretty
set :rvm1_ruby_version, "ruby-2.1.5"
# Default value for :linked_files is []
set :linked_files, %w{config/database.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle}
set :linked_dirs, fetch(:linked_dirs) + %w{public/system public/uploads}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :pty, true
# Default value for keep_releases is 5
set :keep_releases, 5
# set config unicorn.rb, unicorn_init.sh, nginx.conf file permission after deployment
set :file_permissions_roles, :all
set :file_permissions_users, ['username']
set :file_permissions_chmod_mode, "0777"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 1 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
# execute "sudo service nginx restart"
# execute "sudo service unicorn restart"
end
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
desc 'Starts SOLR'
task :reindex do
run "cd #{current_path} && #{rake} RAILS_ENV=#{rails_env} sunspot:solr:reindex"
end
before "deploy:updated", "deploy:set_permissions:chmod"
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
我添加了两个任务(seed、reindex)。但是当我通过命令cap production deploy 进行部署时,我的数据库没有填充种子数据。
此外,我无法开始 + 重新索引我的 Solr 依赖项。
任何帮助将不胜感激!
【问题讨论】:
标签: ruby-on-rails solr capistrano3