I'm relatively new to rails apps, but I've got a rails app thats working locally that I'm trying to deploy to a shared hosting server on DreamHost. I've followed all the wiki's and stackoverflow questions, but an answer for this is still eluding me.
I'm deploying with Capistrano, and I've worked out all the issues to get successful deployments working. However, when I go to access anything that is not a static resource on the site, I am greeted with a 'internal server error' and this error from Passenger:
Internal server error
Passenger encountered the following error:
The application spawner server exited unexpectedly: Unexpected end-of-file detected.
Exception class:
PhusionPassenger::Rack::ApplicationSpawner::Error
Backtrace:
# File Line Location
0 /dh/passenger/lib/phusion_passenger/rack/application_spawner.rb 134 in `start'
1 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 253 in `spawn_rack_application'
2 /dh/passenger/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add'
3 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 246 in `spawn_rack_application'
4 /dh/passenger/lib/phusion_passenger/abstract_server_collection.rb 82 in `synchronize'
5 /dh/passenger/lib/phusion_passenger/abstract_server_collection.rb 79 in `synchronize'
6 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 244 in `spawn_rack_application'
7 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 137 in `spawn_application'
8 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application'
9 /dh/passenger/lib/phusion_passenger/abstract_server.rb 357 in `__send__'
10 /dh/passenger/lib/phusion_passenger/abstract_server.rb 357 in `server_main_loop'
11 /dh/passenger/lib/phusion_passenger/abstract_server.rb 206 in `start_synchronously'
12 /dh/passenger/helper-scripts/passenger-spawn-server 99
I can SSH into the server and manually run 'rails s' to get a server running on port 3000, and everything there works great.
Here's my environment.rb:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
LoLItemDb::Application.initialize!
# potential fix for Dreamhost shared resources
# from: http://stackoverflow.com/a/3214748/189292
require 'rubygems'
require 'rubygems/gem_runner'
ENV['GEM_PATH'] = '/home/gravitydev/ruby/gems:/usr/lib/ruby/gems/1.8'
Gem.clear_paths
deploy.rb:
user = "XXXXXXXXX"
domain = "XXXXXXXXX.com"
database = "mysql.XXXXXXXXX.com"
set :application, "XXXXXXXXX"
set :rails_env, "production"
set :use_sudo, false
# set rake to be verbose for capistrano
# http://stackoverflow.com/questions/7071126/how-can-i-run-rake-with-trace-within-capistrano
set :rake, "#{rake} --trace"
# here we set a custom paths to commands since on Dreamhost
# servers the user path is a bit different
set :bundle_cmd, "/home/#{user}/.gems/bin/bundle"
require 'bundler/capistrano'
# redirect path for whenever, and use bundler to execute it
set :whenever_command, "/home/#{user}/.gems/bin/bundle exec whenever"
require 'whenever/capistrano'
# configure credentials
set :user, user
set :password, "XXXXXXXXX"
# configure git
default_run_options[:pty] = true # Must be set for the password prompt
# from git to work
set :repository, "git@github.com:XXXXXXXXX/XXXXXXXXX.git" # Your clone URL
set :deploy_to, "/home/#{user}/#{domain}"
set :scm, "git"
set :scm_passphrase, "XXXXXXXXX" # The deploy user's password
set :scm_verbose, true
set :git_shallow_clone, 1
# configure deploy location
set :deploy_to, "/home/#{user}/#{domain}"
# setup web server
server domain, :app, :web, :db, :primary => true
#server domain, :app, :web
#role :db, database, :primary => true
# for SSH
# see: http://wiki.dreamhost.com/Capistrano
set :chmod755, "app config db lib public vendor script script/* public/disp*"
# if you want to clean up old releases on each deploy uncomment this:
after "deploy:restart", "deploy:cleanup"
# run the all "LoL" tasks to refresh the database
#after "deploy:restart", "lol:all"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# for Passenger
namespace :deploy do
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end
and GEMFILE: source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'bundler'
gem 'rake'
gem 'sqlite3'
gem 'haml'
gem 'nokogiri'
gem 'json'
gem 'whenever'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
gem 'mysql2'
gem 'rack'
gem 'RedCloth', '4.2.9'
gem 'jquery-rails'
gem 'capistrano'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
Most posts seem to suggest the path to gems is incorrect, but I've made every configuration change I can find by searching Google and documentation from Dreamhost. Any help is greatly appreciated!