can't get rails app to run with lsapi

#1
Hello. I am trying to get a rails app to run with lsapi as described in the litespeed wiki:
http://litespeedtech.com/community/wiki/doku.php?id=litespeed_wiki:ruby_rails

When I try to run the app, I continually get a 503 Service Unavailable error.

Below I have listed everything I did in the install, and my configuration, as well as the errors from the log. I tried to follow the instructions precisely, but I cannot make it work. Can anyone help?

Thanks, Shelby
_________________________________________________

I am running Litespeed 2.1.18 std on Linux. It serves static pages fine.
I installed mysql, created the database, and set database.yaml in the rails app with the correct user name and password. I can use rake migrate successfully to create the tables, so I know that the database connection works.

I have installed ruby and rails. I have installed litespeed ruby lsapi via
gem install ruby-lsapi. I copied the dispatch.lsapi into my rails public directory and made it executable. All the files in the rails app are readable by the server. In order to try and keep it simple, I am setting it up to run only one rails app for this virtual host.

I created a virtual host just for this web app. its config:
virtual host root: /absolute/path/to/railsapp/ (note - directory above public)
config file: /absolute/path/to/railsapp/config.xml
enable script: yes
restrained: no
GENERAL TAB
document root: /absolute/path/to/railsapp/public/
enable gzip: yes
customized error pages: 404 not found -- /dispatch.lsapi
EXTERNAL APPS
I created a lsapi app...
name: RubyRailsLSAPI
address: uds://tmp/lshttpd/rubyrailslsapi.sock
max connections: 10
environment:RAILS_ENV=production
LSAPI_CHILDREN=10
initial request timeout: 5
retry timeout: 5
persistent connection: yes
response buffering: no
command: /absolute/path/to/railsapp/public/dispatch.lsapi
CONTEXT
I created a LiteSpeedAPI context
URI: /dispatch.lsapi
LSAPI App: [VHostLevel] RubyRailsLSAPI

other than these settings, I left everything else blank.
I saved everything and restarted the server. I try to access the railsapp like this:
http://test.virtualhostname.org/login/login
and receive a 503 service unavailable error
Here is what my log shows:

2006-08-05 23:59:57.674 INFO [192.168.0.101:57801-0#mta_pmta] File not found [/absolute/path/to/railsapp/public/login/login]
2006-08-05 23:59:57.675 INFO [uds://tmp/lshttpd/rubyrailslsapi.sock] Connection refused, restart!
2006-08-05 23:59:57.676 INFO [uds://tmp/lshttpd/rubyrailslsapi.sock] Connection refused, restart!
2006-08-05 23:59:57.676 INFO [uds://tmp/lshttpd/rubyrailslsapi.sock] Connection refused, restart!

It seems to be looking for an actual file at the URL, rather than executing the rails application at that controller and method.

Note that this webapp does run fine on my development machine under webrick with the url:
http://127.0.0.1/login/login
 
#3
dispatch.lsapi

I tried to run dispatch.lsapi from the command line. The first thing I realized is that dispatch.lsapi expects ruby to be in /usr/local..., but mine is in /usr, so I fixed that.

Then I ran it again, and I got this error, which I do not understand:
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- lsapi (MissingSourceFile)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
from ./dispatch.lsapi:8

Pretty puzzled about what this means...

Thanks for your help.
Shelby
 
#4
a bit of progress

I installed the ruby-lsapi by hand - downloaded version 1.4 and installed the tar.gz file manually.

Now when I run the dispatch.lsapi from the command line, the error in the above message is gone, and I see in the terminal:
/usr/local/lib/site_ruby/1.8/i486-linux/lsapi.so: warning: already initialized constant ENV

that looks better...

However, after a server restart, I still get a 503 error page and this in the logs:

2006-08-06 16:22:57.335 INFO [192.168.0.101:58535-0#mta_pmta] File not found [/absolute/path/to/railsapp/public/login/login]
2006-08-06 16:22:57.335 INFO [uds://tmp/lshttpd/rubyrailslsapi.sock] Connection refused, restart!
2006-08-06 16:22:57.336 INFO [uds://tmp/lshttpd/rubyrailslsapi.sock] Connection refused, restart!
2006-08-06 16:22:57.336 INFO [uds://tmp/lshttpd/rubyrailslsapi.sock] Connection refused, restart!

Still wondering what is wrong...

Shelby
 

mistwang

LiteSpeed Staff
#5
At least, dispatch.lsapi works properly now. :)
The "File not found" error is normal.
Have you set "Auto Start" to "yes" for the "RubyRailsLSAPI" application?
Your "initial request timeout" should be increased, maybe like "60".
Please check if the file "/tmp/lshttpd/rubyrailslsapi.sock" exists, do "ps -ef | grep ruby", see if any ruby instance is running, you should see two at least.
 
#6
partial success

I think I did not know to turn on auto start. Now I can bring up the first web page of my site, which is a login page.

I changed the Rails environment in the server to development, so I could see the error messages...

There is some kind of problem with the routing of forms. When I submit a form, I get this:
Routing Error
Recognition failed for "/dispatch.lsapi"

Regular links seem to work correctly. For example, the opening login form fails with the above Routing Error. However, if I "fake it" by submitting a URL with the form attributes in the URL, like...
http://test.site.com/login/process_login?login=me&password=test
then the login works fine. So something is wrong with form posts and the dispatch.lsapi. What could this be?

Running the app on the same machine under webrick works fine...
Thanks for your help...
Shelby
 

mistwang

LiteSpeed Staff
#7
the 404 handler in lsws-2.1.18 cannot process post request properly, will be fixed in 2.1.19, please use rewrite rules to dispatch request to rails, for now.
 
#8
success

I removed the custom 404 handler, and added the rewrite rules, and it works. Thanks so much for all your help.

Shelby
 
Top