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:
  • REMOTE SOURCES:

At this point, I took a step back.

First, this linux is on slicehost and I created and duplicated
everything I had from windows on it in terms of what gems it needs.

It has every single gem installed that I have on my development machine.
The only difference is on windows I don’t need to do a require “x-gem
etc.” to get my gems to work.

Secondly, if I go to IRB and do require “rubygems” and then require
“everything else…”, I get => ‘true’

=================

So, where do I stand? What are the biggest issues?

  1. I can’t see errors in my logs to troubleshoot my issues
  2. I’m not sure where I need to require my gems, how to require them
    properly for production, or how to simplify this process to that I can
    access them anywhere.
  3. The rake gems:install is a bad solution for me because I already
    have the gems installed on my system - my app just needs to be able to
    see them. Because my app can’t see them and I’m forced to use a require
    “rubygems” do I have to include every possible gem my app uses, even
    mysql?
  4. What other things can I do to troubleshoot my issues here.

… Very tired … and pretty frustrated and sad right now. I’m losing
too much time and getting to the point that I can’t think straight.
I’ve been told to go here and there, and talk to this person and that
person, visit this IRC channel and that IRC channel. At the end of it
all, I’m not getting the right answers or not getting any answers at
all.

I’m a great troubleshooter. I don’t know how to properly troubleshoot
this issue correctly.

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

On Wed, Aug 12, 2009 at 7:37 AM, Alpha
Blue[email protected] wrote:

production testing and point my virtual host to that.

rake gems:install so I add them there:
WARNING: You don’t have /home/jdezenzio/.gem/ruby/1.8/bin in your PATH,

Posted via http://www.ruby-forum.com/.


Vince Hodges - Founder

604.603.1741

On Aug 12, 3:37 pm, Alpha B. [email protected]
wrote:

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

Hey, there is nothing to worry. you are exactly in a position that I
was in couple of weeks ago. I’ll try my best.

  1. Are you on a shared host or a dedicated environment? ( i guess you
    are on a shared host).

  2. Did you check the path of your environment. Do they include your
    ruby/rails path?

On Aug 12, 3:46 pm, Frederick C. [email protected]
wrote:

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 B. [email protected]:

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

On Aug 12, 3:57 pm, Alpha B. [email protected]
wrote:

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 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:

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?

On Aug 12, 4:20 pm, heimdull [email protected] wrote:

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

Alpha B. wrote:

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.

Yikes! Please see http://c2.com/cgi/wiki?SustainablePace .

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.

What problems? Github generally works very well.

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.

You may be right. But get Cap working once you solve your gem issues.

I have the following issues from start to finish:

(Setup: Using ubuntu hardy,

That’s 8.04, right?

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”

Your friend was incorrect. Take out the require statements.

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.

You’re not unable to view errors; rather, your app is not even starting
(which is why it’s not writing anything to its logfiles). At this
point, you should look in the Apache error logs for more information.

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”

config.gem is correct, but you should follow the example syntax in
environment.rb as far as versions go. (And you shouldn’t need to
require rubygems – nor, I think, mysql.)

Run sudo rake gems:install

WARNING: Installing to ~/.gem since /usr/lib/ruby/gems/1.8 and
/usr/bin aren’t both writable.

This is where it gets bizarre. Sudo should give you write access to
everything. Does /usr/lib/ruby/gems/1.8 actually exist? If not, try
creating it.

WARNING: You don’t have /home/jdezenzio/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.

And you shouldn’t need it in your path, 'cause gem shouldn’t have to
install there.

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:
  • REMOTE SOURCES:

This looks pretty good.

However, if you are having problems installing gems on your deployment
system, the easiest thing to do would be to just unpack the gems into
vendor and check the codebase into the repo with gems.

================

At this point, I took a step back.

First, this linux is on slicehost and I created and duplicated
everything I had from windows on it in terms of what gems it needs.

It has every single gem installed that I have on my development machine.
The only difference is on windows I don’t need to do a require “x-gem
etc.” to get my gems to work.

I’m not sure if you need to on Linux either (don’t recall for sure).
But the config.gem statements tell the app right at startup what it
needs.
[…]

So, where do I stand? What are the biggest issues?

  1. I can’t see errors in my logs to troubleshoot my issues

As I explained above, that is not the problem. Rather, your app is not
starting.

  1. I’m not sure where I need to require my gems, how to require them
    properly for production, or how to simplify this process to that I can
    access them anywhere.

Learn about rake gems:unpack .

  1. The rake gems:install is a bad solution for me because I already
    have the gems installed on my system - my app just needs to be able to
    see them. Because my app can’t see them and I’m forced to use a require
    “rubygems” do I have to include every possible gem my app uses, even
    mysql?

No. That’s what config.gem is for. Or you could use rake gems:unpack .

  1. What other things can I do to troubleshoot my issues here.

… Very tired … and pretty frustrated and sad right now. I’m losing
too much time and getting to the point that I can’t think straight.

Then just take a break before you start making stupid mistakes. I know
it may feel like you have no time to lose here, but trust me, putting it
all away for a few hours and doing something else will save time.

I’ve been told to go here and there, and talk to this person and that
person, visit this IRC channel and that IRC channel. At the end of it
all, I’m not getting the right answers or not getting any answers at
all.

One other idea: you might want to try deploying an empty Rails app just
to make sure that Passenger and Apache are working OK together.

I’m a great troubleshooter. I don’t know how to properly troubleshoot
this issue correctly.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

adding to my topic post above,…

When using config.gem in environment.rb are those case sensitive? Or,
lower case like requires?

It should be RedCloth NOT redcloth…

On Aug 12, 8:52 am, Alpha B. [email protected]

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?

Alpha B. wrote:

adding to my topic post above,…

When using config.gem in environment.rb are those case sensitive? Or,
lower case like requires?

Always assume case sensitivity. Ruby is case-sensitive, and so are most
*nix filesystems.

Come to think of it, that’s probably your problem: the gem is RedCloth,
IIRC, not redcloth.

(At some point, you probably want to ditch RedCloth for rdiscount, but
you don’t have to do that now.)

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

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”

Updated the new pastie with everything:

http://pastie.org/581497

It contains:

environment.rb with libs
gems list
rake gems
and apache error logs