VPS, Passenger & Gems

vps

#1

After a failed server migration which killed one of my Ruby-based sites (not Rails!), I decided to modernize the code behind the site.

I enabled VPS. I migrated a new development subdomain over to it. I configured the domain for Passenger (Rack) operation.

After a couple of false starts where I had to clear my browser cache so that my.subdomain.com mapped to the VPS version and not the shared server version, my “Hello World!” test resulted in a “Web Application could not be started” error page.

The error message pointed to a missing gem: rack

A ‘gem list --local’ revealed no gems installed. Imagine my surprise.

Are VPS site admins supposed to install every single nut & bolt behind the services that DreamHost offers?

If that’s the case, I don’t mind. It would have been nice to know that up front, though.
[hr]
More fun.

I created an admin user. When I login using the admin user, ‘gem list --local’ lists all kinds of gems.

Running ‘gem environment’ while logged in as each user shows different paths.


#2

I finally figured out the problem with both the VPS’d domain and my original Dice Server, without help from DreamHost no less.

This all started when DreamHost moved my domain to a new server 8 days ago. Over those 8 days, my dice service was down due to its inability to load the mysql gem.

Note that my application is a native Ruby application. It is not a Rails app. It is not a Sinatra app. The domain does not use Passenger.

The only response from support over those 8 days was that a new Passenger configuration may have broken the old ways of doing things. This, in spite of my site not using Passenger.

This response from the support team is why I decided to try to use Passenger on a VPS system, but that system didn’t work “out of the box” either.

So, back to debugging the native Ruby application…

Running the Ruby app from an SSH session showed the error. When I updated the code to ‘require “rubygems”’ before requiring mysql, the app worked from the SSH session. It did not work from a browser connection, however.

The difference between the SSH session and the browser connection, in spite of the fact that the app is run as the same user, is that the SSH connection defined the GEM_PATH environment variable. This value specifies the paths that the rubygems library will use to search for gems. When run as the browser, GEM_PATH was not defined and another path was used as a default: /.gems/ruby/1.8

Note that the system-wide gem repository (/usr/lib/ruby/gems/1.8) is not included in the list of search paths, leading to a huge amount of system-wide gems to be left unused.

I somehow doubt that this was the desired result. Because of this restriction to user-installed gems, my Dice Roller failed to run and Passenger failed to run out of the box b/c the rack gem was not found.

To get around this, I used the Gem.use_paths method to hard-code the search path to the system gem path if GEM_PATH was not defined.

After 8 days, my site is back up and running.


#3

may i ask one question?
what is the diferent between VPS and Dedicated Servers.


#4

A dedicated server, you would be the only customer on the hardware.

A VPS, is a virtual machine. Many VPS’s share the same physical hardware, but to the user it appears more like a dedicated space (as opposed to shared hosting).