LiteSpeed Support Forums

LiteSpeed Support Forums (http://www.litespeedtech.com/support/forum/index.php)
-   Ruby/Rails (http://www.litespeedtech.com/support/forum/forumdisplay.php?f=20)
-   -   LSAPI and Shared Hosting not working (http://www.litespeedtech.com/support/forum/showthread.php?t=6381)

andyf 11-19-2012 07:43 AM

LSAPI and Shared Hosting not working
 
The wiki regarding RoR in a shared environment is pretty short:
http://www.litespeedtech.com/support...:rails_hosting

It says to enable the 'Rails shared hosting', it doesn't even go into detail about installing Rails or the LSAPI, one presumes that comes from the other two guides.

However, having done the install, enabled the shared hosting for rails, the error_log show:

Code:

2012-11-19 15:36:51.291 [INFO] [127.0.0.1:51156-0#APVH_exmaple.com:lsapi] connection to [/tmp/lshttpd/APVH_example.com:testApp.sock] on request #0, confirmed, 0, associated process: -1, running: 0, error: Connection reset by peer!
the stderr log shows:
Code:

2012-11-19 15:36:51.622 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `require': cannot load such file -- config/environment (LoadError)
2012-11-19 15:36:51.622 [STDERR]        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `<main>'
2012-11-19 15:36:51.974 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `require': cannot load such file -- config/environment (LoadError2012-11-19 15:36:51.974 [STDERR] )
        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:131:in `<main>'


This file does exist, and actually if you strace the lsws process it shows the file being accessed at the RoR application location within the user account.
Code:

926369 open("config/environment.rb", O_RDONLY <unfinished ...>
926369 <... read resumed> "# Load the rails application\nrequire File.expand_path('../application', __FILE__)\n\n# Initialize the rails application\nRor::Application.initialize!\n", 147) = 147

Anyone have any suggestions here?

mistwang 11-20-2012 08:13 AM

change that line to

Quote:

require './config/environment'

andyf 11-21-2012 01:50 AM

Thanks, that worked, but now there's another error:

Code:

#
2012-11-21 10:02:53.833 [STDERR] /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- initializer (LoadError)
        from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
        from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:133:in `<main>'

Looking at line 133, it's another 'require':


Code:

    require 'initializer'

mistwang 11-21-2012 01:47 PM

Looks like there is no enough information for litespeed to detect the version of Rails being used, and it defaults to Rails 2.3 branch of code.
If the Rails app involved is >2.3 release, you should set "RAILS_GEM_VERSION" variable in "config/environment.rb" explicitly for that application.

andyf 11-22-2012 01:10 AM

Thanks, again another error:

Code:

2012-11-22 09:08:33.770 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `require')
        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `<main>'
2012-11-22 09:08:33.771 [STDERR] cannot load such file -- lsapi (LoadError2012-11-22 09:08:33.770 [STDERR] : 2012-11-22 09:08:34.346 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `require': cannot load such file -- lsapi (LoadError)
2012-11-22 09:08:34.346 [STDERR]        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `<main>'
2012-11-22 09:08:34.920 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `require': cannot load such file -- lsapi (LoadError)
2012-11-22 09:08:34.921 [STDERR]        from /usr/local/lsws/fcgi-bin/RailsRunner.rb:29:in `<main>'

I'm surprised by the amount of problems getting this working. Would you consider the ruby LSAPI to be production ready?

mistwang 11-23-2012 08:29 AM

Those errors are due to Ruby/Gem/Rails update. It was working well in production for many years.

For the "require lsapi" error, you need to locate the gem folder, like
/usr/lib64/ruby/gems/1.9.1/gems/ruby-lsapi-4.0/

Just follow the instruction in README to manually install it into ruby system folder, it can be always located by ruby.

andyf 11-27-2012 04:24 AM

Thanks. That has resolved the error, however there is a further error now:

Code:

/usr/local/lsws/fcgi-bin/RailsRunner.rb:91:in `<main>': uninitialized constant RAILS_ROOT (NameError)
2012-11-27 12:22:51.283 [STDERR] /usr/local/lsws/fcgi-bin/RailsRunner.rb:91:in `<main>': 2012-11-27 12:22:51.283 [STDERR] uninitialized constant RAILS_ROOT (NameError)

Since this is due to a Ruby update, will you be issuing a revised version of the Ruby LSAPI runner?

mistwang 11-27-2012 07:30 AM

Yes, there is a updated version of RailsRunner.rb, please manually upgrade to 4.2.1 release with command

/usr/local/lsws/admin/misc/lsup.sh -f -v 4.2.1

andyf 11-27-2012 08:49 AM

That seems to have done the trick, thanks. I think I might be seeing this problem:
http://www.litespeedtech.com/support...87&postcount=8

In so much when running as development and the moment you try to add a route and remove the public/index.html it doesn't actually recognise the changes and actually doesn't even pass the request to the rails handler.

In fact, the HTTP header returns:
Code:

X-Powered-By: PHP/5.4.8
and you can see lsphp5 being run.

Adding any non-existant route such as /foo/bar to the request results in a proper Rails-handled request. It's just when requesting the root of the app that nothing happens.

mistwang 11-27-2012 09:01 AM

Seems you have directory autoindexing enabled. turn off directory index should fix this.


All times are GMT -7. The time now is 01:59 PM.