Ruby/rails seems to be fubar'd

Hello. Any help the community can give me will be greatly appreciated.
I’ve got the server guys who administer my dedicated server working on
my issue, but it’s been two days and they are still at square one.

Let’s start with the history. I’ve been working with ruby for a month
or so now, and am starting to get pretty comfortable with it. I asked
my host (hostgator) to install ruby/rails on my dedicated server so I
can use typo for my blog and run some applications we have in
development.

A couple of days ago, I set forth to install Typo. Got it up on the
server, changed it to production, symlinked it, setup the database and
was ready to run through the install process. Through ssh from my mac,
I initialized the server with script/server and only got a blank page
when I went to my typo site. As soon as I closed terminal, I got a 404
at my typo site. I proceeded to ask the host to check my server for
errors. That’s when the fun began.

The host has been telling me they installed ruby/rails with FastCGI to
work with Apache. Now, since i’m not a server tech, but a programmer,
I’m a little confused. This is what I got this morning while trying to
setup a simple test on the server:

ruby script/server

=> Booting WEBrick…
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-03-09 06:35:38] INFO WEBrick 1.3.1
[2006-03-09 06:35:38] INFO ruby 1.8.4 (2005-12-24) [x86_64-linux]
[2006-03-09 06:35:38] WARN TCPServer Error: Address already in use -
bind(2)
/usr/local/lib/ruby/1.8/webrick/utils.rb:73:in initialize': Address already in use - bind(2) (Errno::EADDRINUSE) from /usr/local/lib/ruby/1.8/webrick/utils.rb:73:in create_listeners’
from /usr/local/lib/ruby/1.8/webrick/utils.rb:70:in
create_listeners' from /usr/local/lib/ruby/1.8/webrick/server.rb:75:in listen’
from /usr/local/lib/ruby/1.8/webrick/server.rb:63:in
initialize' from /usr/local/lib/ruby/1.8/webrick/httpserver.rb:24:in initialize’
from
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:61:in
dispatch' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in require’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
require' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in require’
from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in
`require’
from script/server:3

For starters, it’s telling me that the server is already initialized for
that site. Second, it’s telling me it’s using WEBrick, not FastCGI.
Forgive my ignorance, but am I wrong in assuming it’s NOT using FastCGI?

At this point, the host is not helping much. They’ve admitted they
don’t know what they are up against. Frankly, I don’t know what route
to take at this point. I cannot get anything to run on the server and
never could since they installed ruby/rails.

Again, any help will be greatly appreciated, and if you’re in my area,
I’ll buy you a beer.

The ‘address is already in use’ line is stating that someone else is
already running an application on your specified port (3000 by
default).

I’m not familiar with the FastCGI / Apache config myself, but I’m sure
someone will be providing you with advice on that shortly. I use
Lighttpd for my projects.

Ultimately, you don’t need Webrick. That’s a test environment really
meant for home / shop development.

FastCGI will run as a process on your server and call your rails app
as needed.

I have no idea what is running on port 3000 at this point.
I’m assuming the hosting company just installed WEBrick without looking
into other options. I’m also thinking that it’s not setup properly with
Apache which may be causing the blank pages and 404’s. Anyone can
correct me if I’m wrong.

Hi Greg,

I’m no expert, so this may or may not be helpful, but WEBrick is a
pre-packaged web server that gives you an easy-to-get-started-with
alternative to Apache. You can use either, but not both. Entering
‘ruby
script\server’ starts WEBrick. If you’re going to do that, make sure
you’ve
stopped Apache first.

Check with your hosting folks to find out what’s running on port 3000.
You
can do it on your local Windows machine by opening a Command Window and
entering ‘netstat’. You didn’t mention what OS you’re hosted on, but
all
the OSs I know about have utilities that provide the same functionality.

If it were me, I’d have the hosting folks take it in several steps: 1)
setup RoR without Apache to make sure your base is properly configured,
2)
then replace WEBrick with Apache, 3) then start tweaking stuff like CGI
vs
FastCGI vs …

I’ve only gotten started with RoR myself and will be making the move to
a
hosted arrangement soon, so your difficulties are very much of interest
to
me. I hope you’ll keep us informed.

Best regards,
Bill

----- Original Message -----
From: “Greg” [email protected]
To: [email protected]
Sent: 2006-03-09 6:03 AM
Subject: [Rails] ruby/rails seems to be fubar’d

A couple of days ago, I set forth to install Typo. Got it up on the
setup a simple test on the server:
already in use - bind(2) (Errno::EADDRINUSE)
/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:61:in
`dispatch’
from

/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.r
b:59

    from

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require’
from

/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dep
endencies.rb:214:in

require' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in require’
from

/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dep
endencies.rb:214:in

Greg, I’ve put a few comments in below that may/may not be useful:

On Mar 9, 2006, at 6:03, Greg wrote:

=> Ctrl-C to shutdown server; call with --help for options
[2006-03-09 06:35:38] INFO WEBrick 1.3.1
[2006-03-09 06:35:38] INFO ruby 1.8.4 (2005-12-24) [x86_64-linux]
[2006-03-09 06:35:38] WARN TCPServer Error: Address already in use -
bind(2)

You definitely have something else running on port 3000 of your
server. Is it possible you started WEBrick before and it got pushed
in the background and is still running? If something else is really
running on port 3000 and it SHOULD be, you can always specify a
different port for WEBrick.

For starters, it’s telling me that the server is already
initialized for
that site. Second, it’s telling me it’s using WEBrick, not FastCGI.
Forgive my ignorance, but am I wrong in assuming it’s NOT using
FastCGI?

When your Rails application is being served up by fastcgi through
Apache, you won’t start your production server using script/server.
That will still start your WEBrick/lighttpd server (which you could
use if you wanted to). Apache+Fastcgi basically means your Apache
configuration will be set up so that it serves up the public
directory of your project, and then your .htaccess file is designed
to direct traffic for non-static files to a dispatch.*cgi script. In
other words, you won’t be running script/server to start your
production server. Just make sure your public/.htaccess has the
following line to have dispatch.fcgi instead of dispatch.cgi.

RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

You might take a look at Peak Obsession
fastcgi for additional pointers.

Regards,

Eric

On Mar 9, 2006, at 8:53 AM, Eric Stewart wrote:

You definitely have something else running on port 3000 of your
server. Is it possible you started WEBrick before and it got
pushed in the background and is still running? If something else
is really running on port 3000 and it SHOULD be, you can always
specify a different port for WEBrick.

Specifically you can do:

script/server webrick -p 8765

where 8765 is a non-privileged port (usually between 1025 and 65535).
Chances are you’ll find an available port somewhere in that range, so
you can test your app locally. This won’t solve your problem with
Apache, but it should at least give you some confidence that your app
works somewhere.

Good luck!

David

Bill,
That’s exactly what i’ve been suspecting. I think i’m going to have
them start from scratch. Remove ruby/rails. Install ruby and rails
with lighttpd or fastCGI. I think the later might be easier to
configure mulitple hosting accounts using ruby since I can put in the
httpd.conf file that the site is using ruby.

The other thing I need to keep in mind is that the server will be
getting ALOT of traffic. Right now, the site we are going to replace
with ruby is getting around 3k uniques with around 20k pageviews per day
and expected to triple next month when the ruby version goes up.

Which will work better for this senario? FastCGI or Lighttpd??

I will definitely keep you guys informed.

Bill W. wrote:

Hi Greg,

I’m no expert, so this may or may not be helpful, but WEBrick is a
pre-packaged web server that gives you an easy-to-get-started-with
alternative to Apache. You can use either, but not both. Entering
‘ruby
script\server’ starts WEBrick. If you’re going to do that, make sure
you’ve
stopped Apache first.

Check with your hosting folks to find out what’s running on port 3000.
You
can do it on your local Windows machine by opening a Command Window and
entering ‘netstat’. You didn’t mention what OS you’re hosted on, but
all
the OSs I know about have utilities that provide the same functionality.

If it were me, I’d have the hosting folks take it in several steps: 1)
setup RoR without Apache to make sure your base is properly configured,
2)
then replace WEBrick with Apache, 3) then start tweaking stuff like CGI
vs
FastCGI vs …

I’ve only gotten started with RoR myself and will be making the move to
a
hosted arrangement soon, so your difficulties are very much of interest
to
me. I hope you’ll keep us informed.

Best regards,
Bill

On Thursday, March 09, 2006, at 2:39 PM, Greg N. wrote:

and expected to triple next month when the ruby version goes up.

Which will work better for this senario? FastCGI or Lighttpd??

Greg,

lighttpd is a webserver, just like Apache. FastCGI is a way to keep
multiple CGI (in this case Rails dispatcher) processes alive constantly.
You can use FastCGI with lighty just as well, and indeed it’s the most
common way. Others are SCGI and Mongrel, but FastCGI is probably the
most common.

You don’t need to reinstall Ruby or Rails to get lighty and fastCGI
running. Just install them and ruby fastcgi bindings and you should be
all set. There’s plenty of resources available in the net, just google
for “lighttpd rails”.

//jarkko

Here’s an update on my issue. Seems like a lot of jumping through hoops
here.

The host got a sample application working on my dedicated server, but
i’m still not satisified with my results so far. What I have to do to
set up a rails application doesn’t feel right to me. What I have to do
is:

  1. ssh into the my server.
  2. cd into the root
  3. enter command: rails appname
  4. with ftp replace the files in appname directory with working files
  5. symlink the public to the root of the account.

When I went through these steps, I didn’t get a working application
anyway. I’m told fastcgi is working. The host did these steps and got
one working, but I cannot. I must be missing something.

What’s frustrating is that I own this server. Why should I have to go
to dreamhost or someplace to get rails hosting?

So what you’re saying is, with FastCGI, there’s no need to start
anything. Apache is configured for ruby apps, and they “just work”.
That would solve all of our problems.

Does lighttpd have to be installed along with fastcgi bindings?
I really wish the hosting company would let me know exactly what they
installed, but I don’t get any replies to that question when I ask.

Jarkko L. wrote:

On Thursday, March 09, 2006, at 2:39 PM, Greg N. wrote:

and expected to triple next month when the ruby version goes up.

Which will work better for this senario? FastCGI or Lighttpd??

Greg,

lighttpd is a webserver, just like Apache. FastCGI is a way to keep
multiple CGI (in this case Rails dispatcher) processes alive constantly.
You can use FastCGI with lighty just as well, and indeed it’s the most
common way. Others are SCGI and Mongrel, but FastCGI is probably the
most common.

You don’t need to reinstall Ruby or Rails to get lighty and fastCGI
running. Just install them and ruby fastcgi bindings and you should be
all set. There’s plenty of resources available in the net, just google
for “lighttpd rails”.

//jarkko

Greg N. wrote:

The host got a sample application working on my dedicated server, but
i’m still not satisfied with my results so far. What I have to do to
set up a rails application doesn’t feel right to me. What I have to do
is:

  1. ssh into the my server.
  2. cd into the root
  3. enter command: rails appname
  4. with ftp replace the files in appname directory with working
    files
  5. symlink the public to the root of the account.

For starters, you should skip steps 1 - 3. You already have a working
application on your local machine. There is no advantage of creating an
application that you are going to overwrite. Also, I think that you mean
home (in 2) or perhaps document root (in 4), when you say root,
otherwise you wouldn’t be able to create a directory without elevated
privileges. It would be helpful to you in understanding this problem if
you were to be more clear in using these terms.

There at least 3 different directories that you are talking about:

The directory where your application lives on the file system. Where is
appname? Is it in /Users/gregn/appname (ie under your home directory)?
is it in some arbitrary location on the file system like
/opt/exports/userspace/gregn/appname? It doesn’t matter, except that you
must have a clear idea where this is. Let assume for clarity that you
are ftp’ing your app to /Users/gregn/appname

The Document Root of your web server. Again, this could be anywhere on
your server. Since this is a dedicated server, this is something like,
/var/www/html.

So when you do step 5, what exactly are you doing?
ln -s /Users/gregn/appname/public /var/www/html or something else?

If you are, and assuming your web server is properly configured, and
your routings are correct, or you have an index page in your public
directory, then you can see your application at

http://yourhost.com/public/ or more generally for a rails app
http://yourhost.com/public/controller/action/

When I went through these steps, I didn’t get a working application
anyway. I’m told fastcgi is working. The host did these steps and got
one working, but I cannot. I must be missing something.

How do you know you didn’t get a working application? What are the error
messages in your browser? What about the error logs for your web server?

What’s frustrating is that I own this server. Why should I have to go
to dreamhost or someplace to get rails hosting?

Because Dreamhost has worked to make this setup painless, and they know
what they are doing.

Ray

Ray B. wrote:

For starters, you should skip steps 1 - 3. You already have a working
application on your local machine. There is no advantage of creating an
application that you are going to overwrite. Also, I think that you mean
home (in 2) or perhaps document root (in 4), when you say root,
otherwise you wouldn’t be able to create a directory without elevated
privileges. It would be helpful to you in understanding this problem if
you were to be more clear in using these terms.

I kind of figured that those were reduntant, but that’s what the host
“told” me to do.

I’m sorry. I did mean home. The directory setup is as follows:

Home
– public_ftp
– public_html
------ blog (symlinked to public)
– typo
------ all typo directories

There at least 3 different directories that you are talking about:

The directory where your application lives on the file system. Where is
appname? Is it in /Users/gregn/appname (ie under your home directory)?
is it in some arbitrary location on the file system like
/opt/exports/userspace/gregn/appname? It doesn’t matter, except that you
must have a clear idea where this is. Let assume for clarity that you
are ftp’ing your app to /Users/gregn/appname

The Document Root of your web server. Again, this could be anywhere on
your server. Since this is a dedicated server, this is something like,
/var/www/html.

So when you do step 5, what exactly are you doing?
ln -s /Users/gregn/appname/public /var/www/html or something else?

Step 5 would be ln -s ~/typo/public ~/public_html/blog

If you are, and assuming your web server is properly configured, and
your routings are correct, or you have an index page in your public
directory, then you can see your application at

http://yourhost.com/public/ or more generally for a rails app
http://yourhost.com/public/controller/action/

When I went through these steps, I didn’t get a working application
anyway. I’m told fastcgi is working. The host did these steps and got
one working, but I cannot. I must be missing something.

How do you know you didn’t get a working application? What are the error
messages in your browser? What about the error logs for your web server?

Because what I was getting was simply a directory list.

What’s frustrating is that I own this server. Why should I have to go
to dreamhost or someplace to get rails hosting?

Because Dreamhost has worked to make this setup painless, and they know
what they are doing.

Ray

The latest is that I’ve got applications working on the server. I made
a simple testapp that just outputs a welcome and it ran fine. Typo on
the other hand is returning “Application Error, Typo failed to start
properly”

There is nothing in the log directory for me to diagnose the problems.

We found the problem.
It was the fcgi gem that was corrupt. We had to install the fcgi
developer kit then re-install the fcgi gem. That took care of all of
our problems.

We documented the process we used to install ruby, rails and fcgi with
apache on our Redhat server at http://www.busyashell.com in case anyone
else runs into the same issues.

Thanks for the input guys!