當我們部署到我們的服務器時,所有部署都很好,但是我們後來發現錯誤「Gemfile not found」。起初我以爲這是nginx不開始,但如果我重新啓動盒子,錯誤消失,應用程序完美工作。我們正試圖確定爲什麼會發生這種情況,以及如何解決這個問題。截至目前,我不知道從哪裏開始,我似乎沒有研究「谷歌」的答案。cap v3 rails 4乘客部署Web應用程序無法啓動,因爲找不到Gemfile
服務器設置和部署的崩潰:
- 軌道4
- rbenv
- 紅寶石2.1.0
- Capistrano的V3
- 乘客
- 服務器建立與廚師
的Capfile:
require 'pry'
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https://github.com/capistrano/chruby
# https://github.com/capistrano/bundler
# https://github.com/capistrano/rails/tree/master/assets
# https://github.com/capistrano/rails/tree/master/migrations
#
# require 'capistrano/rvm'
require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
# require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
的deploy.rb:
set :application, 'api'
set :scm, :git
set :repo_url, '[email protected]:PlacewiseMedia/API.git'
set :branch, 'develop'
set :deploy_to, '/home/apps/api'
set :deploy_via, :remote_cache
set :keep_releases, 10
set :user, 'deploy'
set :use_sudo, false
set :rbenv_type, :system
set :rbenv_ruby, '2.1.0'
set :rbenv_path, '/opt/rbenv'
namespace :deploy do
desc 'Restart application'
task :restart_application do
on roles(:app), in: :sequence, wait: 5 do
spacer("Setting up restart file")
execute "mkdir -p #{release_path}/tmp ; touch #{release_path}/tmp/restart.txt"
spacer("Restarting the nginx service")
execute "sudo service nginx restart"
spacer()
end
end
desc 'Run Migrations'
task :update_database do
on roles(:app), in: :sequence, wait: 5 do
within(release_path) do
with rails_env: fetch(:rails_env) do
spacer("Updating the database")
execute :rake, "db:migrate", "--trace"
spacer()
end
end
end
end
desc 'Create application symlinks'
task :shared_links do
on roles(:app), in: :sequence, wait: 5 do
spacer("Creating application symlinks")
execute "rm #{release_path}/config/database.yml"
execute "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml"
execute "ln -s #{shared_path}/config/secrets.yml #{release_path}/config/secrets.yml"
execute "ln -s #{shared_path}/bin/passenger #{release_path}/bin/passenger"
spacer()
end
end
after 'deploy:updated', 'deploy:shared_links'
after :finishing, 'deploy:update_database'
after :finishing, 'deploy:restart_application'
after :finishing, 'deploy:cleanup'
end
namespace :setup do
desc 'Copy the secrets.yml and database.yml files'
task config: ['config/secrets.yml', 'config/database.yml'] do |t|
on roles(:all) do
execute "mkdir -p #{shared_path}/config"
t.prerequisites.each do |file|
upload! file, "#{shared_path}/config"
end
end
end
end
def spacer(desc = nil)
puts "-----------------------------------------------------------------------------"
if desc
puts desc
puts "-----------------------------------------------------------------------------"
end
end
錯誤:
更新09/25:下午2時10 PST
與https://hackhands.com/工作後,我們發現Nginx的多個實例在運行,如下所示:
我可以努力殺死的服務和重啓但它似乎可能沒有通過廚師或我們的帽子部署在服務器上正確配置。如果我按照說明重新啓動盒子,但我們也嘗試了殺死nginx服務。我們發現這也適用。我們的開發團隊正在研究這個問題,但我們仍然對這種情況如何發生或者如何修復感到困惑。
更新09/26:上午11:06 PST
I found where the config comes from on the passenger spinup, if you look in
/etc/service/
you will see the folders for the apps that are on the server. Look at therun
file in the folder you're interested in and you'll see the passenger config. That fires off aruby .bin/passenger start
process, which then fires off the/tmp
nginx process which is hanging on app restart. I've tried restarting all in different combos, the one that seems to work is killing the nginx process, then runningsudo killall ruby
to respawn the new app... not ideal
有沒有可能是你的Gemfile通過.gitignore忽略? – 2014-09-25 01:01:04
聽起來像bundler正在安裝到不同的路徑/ gemset然後rbenv ruby。你正在用rbenv安裝ruby到/ opt/ruby。我將首先確保'capistrano/bundler'的東西安裝捆綁器到rbenv ruby安裝在/ opt/ruby的PATH中。 例如'哪個bundle','哪個ruby',或者添加rbenv知道或者安裝bundler的路徑,這樣你就可以保證rbenv知道它。 – mmay 2014-09-25 01:22:47
@Anlek是的,寶石文件正確過來。 – 2014-09-25 01:31:32