我受雇为基于 Rails 3.0.3 和 RefineryCMS 0.9.9 构建的站点添加一些更改。我是 Rails 和 Capistrano 的新手,所以我尝试对站点进行测试部署,以便掌握使用这些工具的窍门。我下载了该站点的生产版本,并尝试重新部署它。我只更改了 config/deploy.rb 文件中的一些内容,我没有更改 Gemfile 中的任何依赖项或数据库中的任何内容。我尝试使用 github 进行部署,但遇到了 ssh 密钥问题,因此我使用自己的副本进行了部署。我更改了对服务器的所有必要权限,部署工作正常。该网站虽然没有。主页的标题是
Ruby (Rack) application could not be started
These are the possible causes:
There may be a syntax error in the application's code. Please check for such errors and fix them.
A required library may not installed. Please install all libraries that this application requires.
The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.
A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.
因此,我输入了“cap deploy:rollback”来获取以前的正确版本。但是,登录时,仪表板应该出现的位置,我得到一个 500.hmtl 页面。我似乎已登录到该站点,但没有仪表板!
服务器主机是典型的 nginx/0.8.53 + Phusion Passenger 3.0.2 (mod_rails/mod_rack)。错误日志被禁用,所以我找不到任何东西!
以下是我使用的 deploy.rb:
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
#require "rvm/capistrano" # Load RVM's capistrano plugin.
#set :rvm_ruby_string, '1.9.2' # Or whatever env you want it to run in.
#set :rvm_type, :user
#require "bundler/capistrano"
set :application, "xxxxx"
#set :repository "ssh://hg@bitbucket.org/xxxx/xxxxx"
#set :repository, "ssh://git@bitbucket.org/xxxx/xxxxx.git"
set :repository, "git@github.com:xxxx/xxxxx.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :scm_username, 'xxxx'
set :scm_password, proc{Capistrano::CLI.password_prompt('git pass:')}
role :web, "www.xxxxx.gr" # Your HTTP server, Apache/etc
role :app, "www.xxxxx.gr" # This may be the same as your `Web` server
role :db, "www.xxxxx.gr", :primary => true # This is where Rails migrations will run
# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :copy #:remote_cache #:copy
set :keep_releases, 5
set :user, "xxxx"
set :use_sudo, true
# before "deploy:bundle_install", "deploy:install_bundler"
# after "deploy:update_code", "deploy:bundle_install"
after "deploy:update_code", "deploy:remove_packaged_assets"
after "deploy:update_code", "deploy:symlink_assets"
#after "deploy:symlink", "deploy:update_crontab"
namespace :deploy do
task :start do ; end
task :stop do ; end
desc "Symlink shared folders on each release."
task :symlink_assets do
run "ln -nfs #{shared_path}/system #{release_path}/public/system"
end
desc "Remove packaged assets"
task :remove_packaged_assets, :roles => :web do
run "rm -f #{current_path}/public/javascripts/all.js"
run "rm -f #{current_path}/public/stylesheets/all.css"
end
# desc "installs Bundler if it is not already installed"
# task :install_bundler, :roles => :app do
# sudo "sh -c 'if [ -z `which bundle` ]; then echo Installing Bundler; sudo gem install bundler; fi'"
# end
#
# desc "run 'bundle install' to install Bundler's packaged gems for the current deploy"
# task :bundle_install, :roles => :app do
# run "cd #{current_path} && bundle install"
# end
desc "Update the crontab file"
task :update_crontab, :roles => :app, :except => { :no_release => true } do
run "cd #{release_path} && bundle exec whenever --update-crontab #{application}"
end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
end
end