Welcome Guest | Login

After deploying with Capistrano; get a simple 'Index of ...' cgi-page

Hi,

I worked myself through the excellent Capistrano tutorial on this site (however, it didn't work until I found a forum thread on how to fix the 'key verification error' that I got the first 10 times I tried to deploy:cold) and managed to deploy without major errors in the shell.

However, when I browse to my frontpage now, applab.dk, all I get is an 'Index of' page?!

I changed the .htaccess file as I'm supposed to, and that remedied for the error that I got before checking in the changed file.

I did not yet setup databases etc., but I expect that the 'Index' file (for testing purposes, I changed the default Rails-index page and left it there) at least should work on the site?

Thanks in advance,
Br Bo

2008-06-20 06:38 PM

FYI this is what I get when I run deploy:cold:

= = = = = = = = = =

Macintosh-3:applabDK bovittrup$ cap deploy:cold
 * executing `deploy:cold'
 * executing `deploy:update'
** transaction: start
 * executing `deploy:update_code'
applabd@applab.dk's password:
 * executing "svn checkout -q  -r3 svn+ssh://applabd@applab.dk/home/applabd/svn/applabDK/trunk /home/applabd/apps/applabDK/releases/20080620232533 && (echo 3 > /home/applabd/apps/applabDK/releases/20080620232533/REVISION)"
   servers: ["applab.dk"]
Password:
   [applab.dk] executing command
** [out] The authenticity of host 'applab.dk (208.101.17.116)' can't be established.
** RSA key fingerprint is e9:f0:a8:bc:d6:b9:6a:4c:8a:a1:e9:ed:4a:1a:3c:f5.
** Are you sure you want to continue connecting (yes/no)?
** [out] yes
** [out] Warning: Permanently added 'applab.dk,208.101.17.116' (RSA) to the list of known hosts.
** [out] applabd@applab.dk's password:
** [out]
** [out] applabd@applab.dk's password:
** [out]
   command finished
 * executing `deploy:finalize_update'
 * executing "chmod -R g+w /home/applabd/apps/applabDK/releases/20080620232533"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
 * executing "rm -rf /home/applabd/apps/applabDK/releases/20080620232533/log /home/applabd/apps/applabDK/releases/20080620232533/public/system /home/applabd/apps/applabDK/releases/20080620232533/tmp/pids &&\n      mkdir -p /home/applabd/apps/applabDK/releases/20080620232533/public &&\n      mkdir -p /home/applabd/apps/applabDK/releases/20080620232533/tmp &&\n      ln -s /home/applabd/apps/applabDK/shared/log /home/applabd/apps/applabDK/releases/20080620232533/log &&\n      ln -s /home/applabd/apps/applabDK/shared/system /home/applabd/apps/applabDK/releases/20080620232533/public/system &&\n      ln -s /home/applabd/apps/applabDK/shared/pids /home/applabd/apps/applabDK/releases/20080620232533/tmp/pids"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
 * executing "find /home/applabd/apps/applabDK/releases/20080620232533/public/images /home/applabd/apps/applabDK/releases/20080620232533/public/stylesheets /home/applabd/apps/applabDK/releases/20080620232533/public/javascripts -exec touch -t 200806202325.46 {} ';'; true"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
 * executing `deploy:symlink'
 * executing "rm -f /home/applabd/apps/applabDK/current && ln -s /home/applabd/apps/applabDK/releases/20080620232533 /home/applabd/apps/applabDK/current"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
** transaction: commit
 * executing `deploy:migrate'
 * executing "ls -x /home/applabd/apps/applabDK/releases"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
 * executing "cd /home/applabd/apps/applabDK/releases/20080620232533; rake RAILS_ENV=production  db:migrate"
   servers: ["applab.dk"]
   [applab.dk] executing command
** [out :: applab.dk] (in /home/applabd/apps/applabDK/releases/20080620232533)
** [out :: applab.dk] Missing the Rails 2.0.1 gem. Please `gem install -v=2.0.1 rails`, update your RAI
** [out :: applab.dk] LS_GEM_VERSION setting in config/environment.rb for the Rails version you do have
** [out :: applab.dk] installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
** [out :: applab.dk]
   command finished
 * executing `deploy:start'
 * executing "sh -c 'cd /home/applabd/apps/applabDK/current && nohup script/spin'"
   servers: ["applab.dk"]
   [applab.dk] executing command
** [out :: applab.dk] nohup:
** [out :: applab.dk] appending output to `nohup.out'
** [out :: applab.dk]
** [out :: applab.dk] nohup:
** [out :: applab.dk] cannot run command `script/spin'
** [out :: applab.dk] : No such file or directory
** [out :: applab.dk]
   command finished

= = = = =

... AND this is what I get when I run cap:deploy afterwards:

= = = = =

Macintosh-3:applabDK bovittrup$ cap deploy
 * executing `deploy'
 * executing `deploy:update'
** transaction: start
 * executing `deploy:update_code'
applabd@applab.dk's password:
 * executing "svn checkout -q  -r3 svn+ssh://applabd@applab.dk/home/applabd/svn/applabDK/trunk /home/applabd/apps/applabDK/releases/20080620232625 && (echo 3 > /home/applabd/apps/applabDK/releases/20080620232625/REVISION)"
   servers: ["applab.dk"]
Password:
   [applab.dk] executing command
** [out] applabd@applab.dk's password:
** [out]
** [out] applabd@applab.dk's password:
** [out]
   command finished
 * executing `deploy:finalize_update'
 * executing "chmod -R g+w /home/applabd/apps/applabDK/releases/20080620232625"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
 * executing "rm -rf /home/applabd/apps/applabDK/releases/20080620232625/log /home/applabd/apps/applabDK/releases/20080620232625/public/system /home/applabd/apps/applabDK/releases/20080620232625/tmp/pids &&\n      mkdir -p /home/applabd/apps/applabDK/releases/20080620232625/public &&\n      mkdir -p /home/applabd/apps/applabDK/releases/20080620232625/tmp &&\n      ln -s /home/applabd/apps/applabDK/shared/log /home/applabd/apps/applabDK/releases/20080620232625/log &&\n      ln -s /home/applabd/apps/applabDK/shared/system /home/applabd/apps/applabDK/releases/20080620232625/public/system &&\n      ln -s /home/applabd/apps/applabDK/shared/pids /home/applabd/apps/applabDK/releases/20080620232625/tmp/pids"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
 * executing "find /home/applabd/apps/applabDK/releases/20080620232625/public/images /home/applabd/apps/applabDK/releases/20080620232625/public/stylesheets /home/applabd/apps/applabDK/releases/20080620232625/public/javascripts -exec touch -t 200806202326.36 {} ';'; true"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
 * executing `deploy:symlink'
 * executing "rm -f /home/applabd/apps/applabDK/current && ln -s /home/applabd/apps/applabDK/releases/20080620232625 /home/applabd/apps/applabDK/current"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished
** transaction: commit
 * executing `deploy:restart'
 * executing "/home/applabd/apps/applabDK/current/script/process/reaper"
   servers: ["applab.dk"]
   [applab.dk] executing command
** [out :: applab.dk] Missing the Rails 2.0.1 gem. Please `gem install -v=2.0.1 rails`, update your RAI
** [out :: applab.dk] LS_GEM_VERSION setting in config/environment.rb for the Rails version you do have
** [out :: applab.dk] installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
** [out :: applab.dk]
   command finished
 * executing `after_deploy'
 * executing "chmod 755 /home/applabd/apps/applabDK/current/app && chmod 755 /home/applabd/apps/applabDK/current/config && chmod 755 /home/applabd/apps/applabDK/current/db && chmod 755 /home/applabd/apps/applabDK/current/lib && chmod 755 /home/applabd/apps/applabDK/current/public && chmod 755 /home/applabd/apps/applabDK/current/vendor && chmod 755 /home/applabd/apps/applabDK/current/script && chmod 755 /home/applabd/apps/applabDK/current/tmp && chmod 755 /home/applabd/apps/applabDK/current/public/dispatch.cgi && chmod 755 /home/applabd/apps/applabDK/current/public/dispatch.fcgi && chmod 755 /home/applabd/apps/applabDK/current/public/dispatch.rb"
   servers: ["applab.dk"]
   [applab.dk] executing command
   command finished

= = = = =

/Bo

2008-06-20 06:47 PM

Hi Bobo,

I have now created a sym link from the public_html to apps/<railsapp>/current/public. Now your application is running fine. Please verify it from your end and also execute a "cap deploy" command now and verify if the issue is still persisting.

2008-06-20 08:17 PM

Hi,

Thank you for a fast responxe that helped until I ran cap deploy. When deploying now the app stops responding and I get:

= = = = = = = = = =

Macintosh-3:applabDK bovittrup$ cap deploy
 * executing `deploy'
 * executing `deploy:update'
** transaction: start
 * executing `deploy:update_code'
applabd@applab.dk's password:
Connection closed by 208.101.17.116
svn: Connection closed unexpectedly
*** [deploy:update_code] rolling back
 * executing "rm -rf /home/applabd/apps/applabDK/releases/20080621071950; true"
   servers: ["applab.dk"]
Password:
   [applab.dk] executing command
   command finished
/usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/recipes/deploy/scm/subversion.rb:58:in `query_revision': tried to run `svn info svn+ssh://applabd@applab.dk/home/applabd/svn/applabDK/trunk  -rHEAD' and got unexpected result "" (RuntimeError)
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/recipes/deploy/scm/base.rb:35:in `send'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/recipes/deploy/scm/base.rb:35:in `method_missing'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/recipes/deploy/scm/base.rb:63:in `local'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/recipes/deploy/scm/base.rb:35:in `method_missing'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/recipes/deploy.rb:37:in `load'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/configuration/variables.rb:87:in `call'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/configuration/variables.rb:87:in `fetch'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/configuration/variables.rb:110:in `protect'
        ... 35 levels...
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/lib/capistrano/cli/execute.rb:14:in `execute'
       from /usr/local/lib/ruby/gems/1.8/gems/capistrano-2.3.0/bin/cap:4
       from /usr/local/bin/cap:19:in `load'
       from /usr/local/bin/cap:19

= = = = = = = = = =

My deploy.rb file looks as follows:

= = = = = = = = = =

# =============================================================================
# REQUIRED VARIABLES
# =============================================================================

# User specific variables

set :domain, "applab.dk"  
set :user, "applabd"            
set :application, "applabDK"  
# set :mongrel_port, "****"      
# set :mongrel_nodes, "*"  


set :rails_env, :production
set :deploy_to, "/home/#{user}/apps/#{application}"
set :chmod755, %w(app config db lib public vendor script tmp public/dispatch.cgi public/dispatch.fcgi public/dispatch.rb)
set :use_sudo, false
set :repository, "svn+ssh://#{user}@#{domain}/home/#{user}/svn/#{application}/trunk"
# set :repository, "http://svn.#{domain}/svn/#{application}/trunk"

# Won't work on windows otherwise, see
# http://groups.google.com/group/capistrano/browse_thread/thread/13b029f75b61c09d
default_run_options[:pty] = true

# =============================================================================
# ROLES
# =============================================================================

role :web, domain
role :app, domain
role :db,  domain, :primary => true

# =============================================================================
# SSH OPTIONS
# =============================================================================
# ssh_options[:keys] = %w(/full/path/to/your/ssh_key/id_rsa)

# =============================================================================
# FCGI TASKS
# =============================================================================

# Uncomment these tasks if using FCGI to serve your Rails Application

desc "FCGI is already running, so we don't really need the spinner script, but we have it create the initial symlink for us"
task :spinner, :roles => :app do
 run "rm -rf /home/#{user}/public_html;ln -s #{current_path}/public /home/#{user}/public_html"
end

desc "Restart the FCGI Process"
task :restart, :roles => :app do
 run "cd #{current_path}; killall dispatch.fcgi"
 cleanup
end

# =============================================================================
# TASKS
# =============================================================================

desc "Set the proper permissions for directories and files on HostingRails accounts"
task :after_deploy do
 run(chmod755.collect do |item|
   "chmod 755 #{current_path}/#{item}"
 end.join(" && "))
end

= = = = = = = = =

Br Bo

2008-06-21 02:27 AM

Hi again,

I recreated the symlink and now the app works fine once again. I guess there must be an error in my deploy.rb file?

Does the spinner get run each time I deploy? Will the symlink need to be re-created each time?

Br Bo

2008-06-21 02:33 AM

Hi,

I now commented the spinner-part out and actually cap deploy works as it should now.

I guess the spinner part is only for the inital deploy?

Br Bo

2008-06-21 02:43 AM

Yes. Which version of Capistrano are you using ?

2008-06-21 08:11 AM

Hi,

I'm using version 2.3.0.

/Bo

2008-06-21 09:48 AM

Could you make sure that you're following the tutorial at http://www.hostingrails.com/forums/wiki_thread/46 ?

2008-06-21 11:30 AM

Hi again,

OK - I ran through that tutorial again (actually think that the cap 2.x tutorial is easier to understand after having read and gone through the cap 1.x one), updated my capfile and deploy.rb and deployment works fine - or so it appears.

My problem now is that I get the feared 'Rails application failed to start properly'. My application is not at all advanced; actually I'm currently trying to deploy only a super-simple app with a Post scaffold. But when I try to go to my controller / index action, I get the error message - i.e. my application is in fact not working at all.

I went through all of the tips on the 'Rails application failed to ...' page on your website, but that didn't reveal any errors in my files.

My production log is empty by the way - or rather; there is no log files at all! Wouldn't the first step be to get log files revealing a bit more about what fails? But how would I ensure that log messages are filled into a log file?

Hope that you can help once again; I'd really like to get an app running soon - and make future deployments of new apps easier than this one ...

Br Bo

2008-06-21 06:53 PM

Hi Bobo,

Initially I got a rails gem missing error. I have installed the required gem and I am no longer getting the 'Rails application failed to start properly error. I am now getting a 500 error caused by missing table "posts". It seems like the tables are not populated into the database. Please have a look at it.

2008-06-21 08:55 PM

Hi,

Thank you - I ran cap deploy:migrate and now it works :) However, to be better at helping myself in future situations like this, could you point me towards how to get the production logging up and running?

/Bo

2008-06-22 03:59 AM

Hi,

Have you checked if the environment is set to production in your app's environment.rb ?

2008-06-22 04:24 AM

Yes: This is my environment.rb file on the server right now:

# Be sure to restart your server when you modify this file

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.0.1' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
 # Settings in config/environments/* take precedence over those specified here.
 # Application configuration should go into files in config/initializers
 # -- all .rb files in that directory are automatically loaded.
 # See Rails::Configuration for more options.

 # Skip frameworks you're not going to use (only works if using vendor/rails).
 # To use Rails without a database, you must remove the Active Record framework
 # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

 # Only load the plugins named here, in the order given. By default, all plugins
 # in vendor/plugins are loaded in alphabetical order.
 # :all can be used as a placeholder for all plugins not explicitly named
 # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

 # Add additional load paths for your own custom dirs
 # config.load_paths += %W( #{RAILS_ROOT}/extras )

 # Force all environments to use the same logger level
 # (by default production uses :info, the others :debug)
 # config.log_level = :debug

 # Your secret key for verifying cookie session data integrity.
 # If you change this key, all old sessions will become invalid!
 # Make sure the secret is at least 30 characters and all random,
 # no regular words or you'll be exposed to dictionary attacks.
 config.action_controller.session = {
   :session_key => '_applabDK_session',
   :secret      => '66cb8887fccfe69e6e3b95d5b1e7f2f88aca2acc4a705760f69267b2820a65cbf121e79ebc08f996df2abb903a58e2099f120286bd1a88e7a3f7a66daf9e689b'
 }

 # Use the database for sessions instead of the cookie-based default,
 # which shouldn't be used to store highly confidential information
 # (create the session table with 'rake db:sessions:create')
 # config.action_controller.session_store = :active_record_store

 # Use SQL instead of Active Record's schema dumper when creating the test database.
 # This is necessary if your schema can't be completely dumped by the schema dumper,
 # like if you have constraints or database-specific column types
 # config.active_record.schema_format = :sql

 # Activate observers that should always be running
 # config.active_record.observers = :cacher, :garbage_collector

 # Make Active Record use UTC-base instead of local time
 # config.active_record.default_timezone = :utc
end

/Bo

2008-06-22 04:41 AM

Hello,

Yeah the following line indicates the environment in which the app should run.

ENV['RAILS_ENV'] ||= 'production'

Please make sure that this line is uncommented.

2008-06-22 05:20 AM

Regards,
Rahul

Hello Guest! In order to post you must be an active client with us, please log in or sign up.