I am very overwhelmed going to production and need help

The title says it all - please bear with me. To let you know where I
stand, I have been working for up to 12 hours a day for 2 months and 2
weeks trying to get my site ready for release. In development (on
windows) it works perfectly. In production (on linux ubuntu) it does
not.

I stopped using capistrano because there are problems with the repo on
github and things aren't working well with that. I figured the easiest
way for the first time would be to create a separate folder for
production testing and point my virtual host to that.

I have the following issues from start to finish:

(Setup: Using ubuntu hardy, apache, passenger, rails 2.3.3, ruby 1.8.6)

Issue One: Last night when I did the manual install and went to my
server, passenger told me that one of my plugin methods wasn't
available. I was subsequently told by a friend that you have to include
"all" gems in environment.rb. So, I put require next to the gems I use
in order:

require "rubygems"
require "redcloth"
require "will_paginate"
require "mysql"

Issue Two: After restarting the server, I was getting an issue about one
of the constants I have in my environment. I disabled the constant in
the two files it exists (because it wouldn't affect things outright).
When running touch restart.txt and going to my site I'm getting an
Internal Server Error 500 message.

I check the logs and there's nothing written to them. Just one line
only on production. Server log has 0.

# Logfile created on Tue Aug 11 13:26:37 +0000 2009

So, I'm unable to view errors or figure out what is going wrong with my
setup.

Issue Three: Another person told me that I don't need to require the
gems in environment rb and that I should just use the config and do a
rake gems:install so I add them there:

  config.gem "rubygems"
  config.gem "redcloth"
  config.gem "will_paginate"
  config.gem "mysql"

Run sudo rake gems:install

WARNING: Installing to ~/.gem since /usr/lib/ruby/gems/1.8 and
          /usr/bin aren't both writable.
WARNING: You don't have /home/jdezenzio/.gem/ruby/1.8/bin in your PATH,
          gem executables will not run.

GEM ENV:

  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby1.8
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /home/jdezenzio/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/",
"http://gems.github.com", "http://gems.github.com"]
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gems.github.com

Hi,

A couple of things to try/check.

1) Look in the apache error logs for the virtual host, passenger may
be reporting issues there.

2) Did you create the DB, migrate it, etc (I know you probably did,
but when you get frustrated sometimes it's the basic things you forgot
to do).

Vince

The title says it all - please bear with me. To let you know where I
stand, I have been working for up to 12 hours a day for 2 months and 2
weeks trying to get my site ready for release. In development (on
windows) it works perfectly. In production (on linux ubuntu) it does
not.

production mode can reveal some flaws because code is loaded
differently. Have you tried running in production mode on your
development machine?

Fred

Hi Joel,

You might get the help you need here but this is primarily a dev list.
You might also try requesting assistance on the rails-deploy list.

Best regards,
Bill

> The title says it all - please bear with me. To let you know where I
> stand, I have been working for up to 12 hours a day for 2 months and 2
> weeks trying to get my site ready for release. In development (on
> windows) it works perfectly. In production (on linux ubuntu) it does
> not.

production mode can reveal some flaws because code is loaded
differently. Have you tried running in production mode on your
development machine?

The thing that can make things easier to work out is to poke around in
script/console - you generally get something more informative that a
boring 500 page.

Fred

If I try script/console, sudo script/console etc., none of those
commands work from my app in linux. It's as if the commands are not in
the right path.

Quoting Alpha Blue <rails-mailing-list@andreas-s.net>:

The title says it all - please bear with me. To let you know where I
stand, I have been working for up to 12 hours a day for 2 months and 2
weeks trying to get my site ready for release. In development (on
windows) it works perfectly. In production (on linux ubuntu) it does
not.

I suggest starting small and expanding from there.

I don't know Slicehost, but one key thing is it sounds like you don't have
full root access. The output from "rake gem:install" looks okay, but you must
add the Gems directory to your path. If you don't know how to do this on
Linux, you have a long way to go, possibly too long and possibly should find a
Window hosting provider.

You should not need to include rubygems in the Rails environment. And Rails
and a mode similar to irb, from you apps root directory, run
"script/console". It defaults to development mode. For test mode,
"script/console test". From there you should be able to create, load,
destroy, update, etc. models. For example, a model called Person:

script/console test
i = Person.new(:first_name => 'John', :last_name => 'Doe')
i.age = 21
i.save
j = Person.find(:all, :conditions => {:first_name => 'John'})
puts i.inspect
puts j.inspect
people = Person.find(:all)
puts people
quit

Start with Webrick as the server running in development mode. This is/was
easy to do as a non-priviledged user and all the debugging is turned on. All
my apps were started when Webrick was the default server, so this may not
apply any more (the default now is Mongrel).

HTH,
  Jeffrey

I'm not afraid of using linux and bash commands are fairly
self-informative. The issue I have right now is I'm not sure where
everything resides path wise so that I can export it correctly:

echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:

If I try script/console, sudo script/console etc., none of those
commands work from my app in linux. It's as if the commands are not in
the right path.

you need to type ruby script/console

Fred

I'm not sure what user that you are running as BUT it looks like you
installed all the gems in your home directory. This might be an issue
if apache/passenger runs as a different user...

Run sudo rake gems:install

WARNING: Installing to ~/.gem since /usr/lib/ruby/gems/1.8 and
          /usr/bin aren't both writable.
WARNING: You don't have /home/jdezenzio/.gem/ruby/1.8/bin in your
PATH,
          gem executables will not run.

When you say there are no errors? have you also checked your
apache_home/logs/error_log ? this is where passenger dumps all the
good stuff if it fails before it even starts.

Also like someone suggested I would use ./script/server on the server
to start the server in production mode but this will output the errors
to your terminal.

ruby script/server
=> Booting Mongrel
=> Rails 2.3.3 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

.. no issues

ruby script/server -e production
=> Booting Mongrel
=> Rails 2.3.3 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

.. no issues

both started with no errors..

is it passenger?

I'm not sure what user that you are running as BUT it looks like you
installed all the gems in your home directory. This might be an issue
if apache/passenger runs as a different user...

More than that if the user passenger runs as can't access the files
that are part of the app then you'll have trouble.

Fred

Okay, lots of good info - thanks guys. I'm making some headway.. here's
where I stand:

First, I removed the requires in environment.rb
I added the config.gem statements for only redcloth and
mislav-will_paginate

I did a restart of my web server just to make sure everything is okay..

Passenger now loads at least and gives me a generic error so I checked
the apache2 error logs.

It says:

Missing these required gems:
  redcloth
  mislav-will_paginate

You're running:
  ruby 1.8.6.111 at /usr/bin/ruby1.8
  rubygems 1.3.5 at /home/jdezenzio/.gem/ruby/1.8,
/usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.

When I run rake gems:install I get the following error:

gem install redcloth
ERROR: could not find gem redcloth locally or in a repository

I'm positive it has to do with my paths at this point. Any idea of what
I need to add to my path to get this working?

It should be RedCloth NOT redcloth...

Here's my current environment.rb file and my gems env information

http://pastie.org/581497

I'm still unable to get rake gems:install to work or for my app to find
the two gems I have already installed which work with IRB and require
"rubygems"

For mislav-will-paginate I have the following in environment.rb:

  config.gem 'mislav-will_paginate', :version => '~> 2.3.8', :lib =>
'will_paginate', :source => 'http://gems.github.com'

The lib field is probably what you need (adjust the version as needed).

Vince

woohoo I fixed it!

I got rid of hectoregm-msyql-ruby and installed mysql gem

I had forgotten that I had hectoregm installed for when I was going to
ruby 1.9.1.

That fixed the issue and my site launched!

Still probably will be errors but here's what it looks like:

http://ncaastatpages.com