Welcome Guest | Login

starting substruct with ruby script/server returns error

I'm a total n00b in rails, so I may have missed something obvious, but when I start my installation of substruct (an ecommerce rails app) using "ruby script/server" I get the following error return:

/home/freefor$ cd substruct
/home/freefor/substruct$ ruby script/server
** Starting Mongrel listening at 0.0.0.0:3000
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/tcphack.rb:12:in `initialize_without_backlog': Address already in use - bind(2) (Errno::EADDRINUSE)
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/tcphack.rb:12:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:93:in `new'
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:93:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:139:in `new'
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:139:in `listener'
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:99:in `cloaker_'
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:50:in `call'
from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel/configurator.rb:50:in `initialize'
 ... 13 levels...
from /home/freefor/substruct/vendor/rails/activesupport/lib/active_support/dependencies.rb:496:in `require'
from /home/freefor/substruct/vendor/rails/railties/lib/commands/server.rb:39
from script/server:3:in `require'
from script/server:3
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting


I used the following instructions to set up substruct:http://www.hostingrails.com/forums/wiki_thread/1http://code.google.com/p/substruct/wiki/InstallingSubstruct

My thoughts are that because I got a different error earlier running script/server (but fixed it) I may have left port 3000 open?  I tried shutting down all processes, but I get the same error.  I also have no idea how to close a TCP connection on port 3000 (I'm a windows guy).

Nagivating to my website produces some default .rb script, and .com:3000 times out on me.

I would appreciate any help and your patience.

2008-04-29 12:12 AM

You don't have dedicated memory added to your account to run your app on mongrel on our servers. You'll need it in chunks of 50 MB/instance. Once you've paid for the memory, we'll assign you a port on the server using which you can deamonize your mongrel instance/instances. Our tutorial below would make more sense to this.
http://www.hostingrails.com/forums/wiki_thread/19

2008-04-29 01:30 AM

I was under the impression that I didn't need 50 megs of memory and mongrel to host a rails app.  I will upgrade when I need to, but I doubt my website is going to skyrocket in popularity as of yet. What do I do to get the thing running without this "mongrel"?

2008-04-29 07:21 AM

Hello,

The script/server is used for testing purpose. This makes the application to run on mongrel (web server). By default it takes the port 3000 for mongrel.

This port 3000 can be used by all the customers hosted on the server. So if one customer is using the port 3000 (I.E running script/server) then you will get the following error.
=
': Address already in use - bind(2) (Errno::EADDRINUSE)
=

Also as I mentioned this script/server is used for testing purpose only and we wont allow anybody to daemonize the mongrel process on this port.

I have checked the status of port 3000 on the server and it is free now. Please run the console command and confirm the current status.

2008-04-29 08:19 AM

Regards,
Rahul
I see, so in my situation, port 3000 with script/server would be for testing purposes only.  To get fcgi working, I just make the .cgi to .fcgi change and it's automatic, or do I have to run something else for my site to start serving rails?

2008-04-29 12:21 PM

Steps for ensuring that application is served by fcgi.

1] Edit the .htaccess file and change lines 2 and 32..
==
(Line 2)  = #AddHandler fastcgi-script .fcgi
(Line 32) =  RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
==
2] Check the shebang line of dispatch.fcgi file.
It should be /usr/local/bin/fcgi

3]Check permissions of .htaccess file and dispatch.fcgi
.htaccess = 644
dispatch.fcgi = 755

4] Also make sure that public directory of your rails app is 755
5] Ensure if the sym-links are pointing correctly(Incase you are using them)

There are also some other reasons for the fcgi to fail. But normally I see such misconfiguration causing issues .

2008-04-29 01:17 PM

Regards,
Rahul
Well, thanks to your help, I got *some* progress :)  When I point to my domain I get a lovely page saying:

Application error
Rails application failed to start properly

Though that could be due to a problem with getting the database to run.  So I checked the substruct installation instructions at http://code.google.com/p/substruct/wiki/InstallingSubstruct) and get the following after running "rake substruct:db:bootstrap":

/home/freefor/substruct$ rake substruct:db:bootstrap
rake aborted!
Access denied for user 'admin'@'localhost' (using password: YES)
(See full trace by running task with --trace)
(in /home/freefor/substruct)
Checking requirements...
Initializing database...
[SUBSTRUCT WARNING]
Mail server settings have not been initialized.
Check to make sure they've been set in the admin panel.

I have added a mysql database through the control panel wizard with a single user, then added the database name, user, and password to the dabatase.yml.

2008-04-29 01:53 PM

Hi - Please make sure that you have given the database user name correctly.It should look like

cpanelusername_databaseusername.

Also please try executing the command as

rake substruct:db:bootstrap RAILS_ENV=production

2008-04-29 02:02 PM

HostingRails Support
Thanks, the username is what I got wrong, and rake was able to execute properly, returning the status for added tables, etc.  script/server also ran fine.

However, when I navigate to mydomainname.com:3000/admin I just time out.  Navigating to mydomainname.com gets the same page I got earlier (I checked to make sure all my fcgi stuff was configured):

Application error
Rails application failed to start properly

Is there a way I can check a more verbose log to see what specifically failed in the application? (the log files in the log directory are empty)

Also, how do I close the script/server test port 3000 so somebody else can use it?

Thanks for all your patience in dealing with my noobishness.

2008-04-29 03:30 PM

Hi Freeform,

You site is loading fine. The error occurred due to the environment mismatch. In the config/environment.rb the line

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

should be uncommented, then only the  application will run in FCGI. Please don't use script/server command on the server because the default port is not available via URL.

2008-04-29 05:30 PM

Wow, thanks it loads up like a charm! You guys are the best.

2008-04-29 05:56 PM

Well, it looks like I have one last thing missing.  I can access any public part of my website, but as soon as I have to log in by navigating to the /admin/ part of the site I get a strange error:
www.mydomain.com has sent an incorrect or unexpected message. Error Code: -12263

I've tried googling this error, but all I get is people complaining about connecting to SSL connections via proxy servers--I don't use a proxy and I can connect to https servers just fine.

I don't think it's a software error with this product either, as I can log in just fine to other websites that use substruct.

Any thoughts?  Do I need to install SSL or something?

2008-04-29 09:42 PM

I checked your app's production log when loading it on a browser and could see there's a redirection set when the access goes to /admin .


Redirected to https://yourdomainname.com/admin
Filter chain halted as [#<ActionController::Filters::ClassMethods::SymbolFilter:0xb7596a0c @filter=:ssl_required>] rendered_or_redirected.


You don't have a SSL VirtualHost set for the domain and hence Apache would throw the said error code. You'll need to purchase a  dedicated IP address and generate a self signed cert or purchase it from an authorized party to get SSL access for the domain.  

2008-04-29 10:00 PM

I should add, this is what the result SHOULD be, according to their demo site:http://substruct.subimage.com/admin

Anything that doesn't involve logging in on my site is identical to the demo.

2008-04-29 10:13 PM

Ah so it IS because I don't have SSL.  So basically I would have to upgrade to a dedicated first?  Are there any issues with having a self-signed cert?

2008-04-29 10:14 PM

Here's another thing I don't understand, if you go to the demo site, it redirects you to /accounts/login from /admin WITHOUT displaying https. Confusing.

2008-04-29 10:23 PM

The SSL redirection seems to be enabled through out in the code, I believe you'll need to have SSL set up for the site to access your Admin page. You may also  take a look at the code  to see if you can disable the SSL  redirection.

2008-04-30 01:24 AM

Well, I decided to go ahead, upgrade to the dedicated, and follow the tutorial at http://www.hostingrails.com/forums/wiki_thread/44) and request a self-signed SSL.

However, it looks like I'm back with more problems :) I'm getting the following output instead of the usual prompts for more information:

/home/myself$ mkdir ssl
/home/myself$ cd ssl
/home/myself/ssl$ ls
/home/myself/ssl$ openssl genrsa -out www.mydomain.com.key 1024
Generating RSA private key, 1024 bit long modulus
.............++++++
....++++++
e is 65537 (0x10001)
/home/myself/ssl$ openssl req -new -key www.mydomain.com.key -out www.mydomain.com.csr
Unable to load config info from /etc/pki/tls/openssl.cnf

At least ./ssl/www.mydomain.com.key was filled with an RSA key.

2008-04-30 09:32 PM

Freeform - please give it  a try again. I've done some tweaking to your ssh access. Please getback to us once you're done with it.

2008-04-30 10:34 PM

I tried running openssl req again and I got the same error:

/home/myself/ssl$ openssl req -new -key www.mydomain.com.key -out www.mydomain.com.csr
Unable to load config info from /etc/pki/tls/openssl.cnf

2008-04-30 10:45 PM

Hi - sorry, I missed the point to tell you that you should logout and login again from your SSH console to give it go again. Let us know if you have a problem with it.    

2008-04-30 10:55 PM

Okay, it looks like it generated a csr file with a key in it.

Oh, and as a warning to anybody else, do not use WinSCP for command line SSH access, it thought the client was hanging when prompting for user input :)

So what's the next step in getting a self-signed cert?

Thanks again for your help.

2008-05-01 07:33 AM

Hello,

Please run the command to obtain the self-signed certificate.

openssl x509 -req -days 365 -in www.yourdomain.com.csr -signkey www.yourdomain.com.key -out www.yourdomain.com.crt

Once it is created do post a ticket to support department to get the SSL certificate installed. Also mention the path were you have uploaded the .crt and .key files

2008-05-01 08:49 AM

Regards,
Rahul
Thanks, it worked great.  I'll post a ticket now.

2008-05-01 10:32 AM


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