LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > Ruby Setup - LSAPI

Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2006, 09:30 PM
Xorlev Xorlev is offline
Senior Member
 
Join Date: Nov 2005
Posts: 58
Default Ruby Setup - LSAPI

Okay, so I'm setting up Ruby (not Ruby on Rails) to work with LSWS with the new LSAPI module, and I need a little help. I decided to use the dispatcher, so I created a LSAPI module with a url of a /tmp/lshttpd/ruby_ns.sock, and the command being the lsruby_runner.rb script. I added a Script Handler for .rb, and it's returning a 503...I know I'm doing something wrong, which is why I'm asking for a little help here.
Reply With Quote
  #2  
Old 04-27-2006, 09:44 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,585
Have you built and installed the ruby extension? Is execution bit enabled for ruby_runner.rb?
For trouble shooting, please check lsws/logs/error.log and stderr.log
Reply With Quote
  #3  
Old 04-27-2006, 10:01 PM
Xorlev Xorlev is offline
Senior Member
 
Join Date: Nov 2005
Posts: 58
Yes, I built and installed the Ruby extension, and it is chmodded to allow execution.

Log:

Code:
2006-04-28 00:02:44.121 [DEBUG] [66.243.195.111:63346-0#Nanoshock] New request:
        Method=[GET], URI=[/ruby/testcgi.rb],
        QueryString=[]
        Content Length=0
2006-04-28 00:02:44.121 [DEBUG] [66.243.195.111:63346-0#Nanoshock] Find context with URI: [/], location: [/home/nano/public_html/]
2006-04-28 00:02:44.122 [DEBUG] [66.243.195.111:63346-0#Nanoshock] Find handler [RubyLSAPI] for [.rb]
2006-04-28 00:02:44.122 [DEBUG] [66.243.195.111:63346-0#Nanoshock] processContextPath() return 0
2006-04-28 00:02:44.122 [DEBUG] [66.243.195.111:63346-0#Nanoshock] run lsapi processor.
2006-04-28 00:02:44.122 [DEBUG] [uds://tmp/lshttpd/ruby_ns.sock] request [66.243.195.111:63346-0#Nanoshock:lsapi] is assigned with connection!
2006-04-28 00:02:44.122 [DEBUG] [66.243.195.111:63346-0#Nanoshock:lsapi] [ExtConn] reconnect()
2006-04-28 00:02:44.122 [DEBUG] [66.243.195.111:63346-0#Nanoshock:lsapi] connection to [uds://tmp/lshttpd/ruby_ns.sock] on request 0, error: No such file or directory!
2006-04-28 00:02:44.122 [DEBUG] [66.243.195.111:63346-0#Nanoshock:lsapi] [ExtConn] close()
2006-04-28 00:02:44.122 [DEBUG] [uds://tmp/lshttpd/ruby_ns.sock] No Request has been processed successfully through this connection, the maximum connections allowed will be reduced!
2006-04-28 00:02:44.122 [INFO] [uds://tmp/lshttpd/ruby_ns.sock] Connection refused, restart!
etc. until it gives up and sends the error.
Reply With Quote
  #4  
Old 04-28-2006, 07:31 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,585
Don't know what exactly is the problem, below is our RubyRunner configuration, you can give it a try.


Code:
Name RubyRunner 
Address uds://tmp/lshttpd/rubyrunner.sock 
Max Connections 10 
Environment N/A 
Initial Request Timeout (secs) 60 
Retry Timeout (secs) 0 
Persistent Connection Yes 
Connection Keepalive Timeout N/A 
Response Bufferring No 
Auto Start Yes 
Command $SERVER_ROOT/fcgi-bin/lsruby_runner.rb 
Back Log 10 
Instances 10
Reply With Quote
  #5  
Old 05-02-2006, 05:45 PM
Xorlev Xorlev is offline
Senior Member
 
Join Date: Nov 2005
Posts: 58
Okay, it's halfway working now (no more errors in log), but now it returns a 500 error.

Settings:

Code:
Name	RubyRunner
Address	uds://tmp/lshttpd/rubyrunner.sock
Max Connections	10
Environment	N/A
Initial Request Timeout (secs)	60
Retry Timeout (secs)	0
Persistent Connection	Yes
Connection Keepalive Timeout	N/A
Response Bufferring	No
Auto Start	Yes
Command	$SERVER_ROOT/fcgi-bin/lsruby_runner.rb
Back Log	10
Instances	10
Log:

Code:
2006-05-02 20:40:05.480	DEBUG	[64.191.7.230:80] New connection from 64.191.7.230:37065.
2006-05-02 20:40:05.480	DEBUG	[64.191.7.230:80] 1 connections accepted!
2006-05-02 20:40:05.481	DEBUG	[64.191.7.230:37065-0] HttpIOLink::handleEvents() events=1!
2006-05-02 20:40:05.481	DEBUG	[64.191.7.230:37065-0] HttpConnection::onReadEx(), state: 0!
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0] readToHeaderBuf().
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0] Read from client: 313
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0] read 313 bytes to header buffer
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0] processHeader() return 0, header state: 3.
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0] readToHeaderBuf() return 0.
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0#RubyNanoshock] New request:
Method=[GET], URI=[/testcgi.rb],
QueryString=[]
Content Length=0
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0#RubyNanoshock] Find context with URI: [/], location: [/home/nano/public_html/ruby/]
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0#RubyNanoshock] Find handler [RubyRunner] for [.rb]
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0#RubyNanoshock] processContextPath() return 0
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0#RubyNanoshock] run lsapi processor.
2006-05-02 20:40:05.482	DEBUG	[uds://tmp/lshttpd/rubyrunner.sock] create new connection succeed!
2006-05-02 20:40:05.482	DEBUG	[uds://tmp/lshttpd/rubyrunner.sock] request [64.191.7.230:37065-0#RubyNanoshock:lsapi] is assigned with connection!
2006-05-02 20:40:05.482	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] [ExtConn] reconnect()
2006-05-02 20:40:05.483	DEBUG	[RubyRunner] add child process pid: 404
2006-05-02 20:40:05.484	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] ExtConn::onWrite()
2006-05-02 20:40:05.484	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] request header is done
2006-05-02 20:40:05.484	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] ExtConn::continueRead()
2006-05-02 20:40:05.484	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] Request body done!
2006-05-02 20:40:05.484	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] ExtConn::suspendWrite()
2006-05-02 20:40:05.484	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] processNewReq() return 0.
2006-05-02 20:40:05.498	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] ExtConn::onRead()
2006-05-02 20:40:05.498	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] LsapiConn::doRead()
2006-05-02 20:40:05.498	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] process packet header 8 bytes
2006-05-02 20:40:05.498	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] process packet header 0 bytes
2006-05-02 20:40:05.538	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] ExtConn::onRead()
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] LsapiConn::doRead()
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] process packet header 8 bytes
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] process response header 8 bytes
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] process packet header 8 bytes
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] [EXT] EndResponse( endCode=0, protocolStatus=0 )
2006-05-02 20:40:05.539	NOTICE	[64.191.7.230:37065-0#RubyNanoshock:lsapi] Premature end of response header.
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] HttpIOLink::continueWrite()...
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] write resumed!
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] HttpIOLink::handleEvents() events=4!
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] HttpIOLink::suspendWrite()...
2006-05-02 20:40:05.539	DEBUG	[64.191.7.230:37065-0#RubyNanoshock:lsapi] HttpConnection::sendHttpError(),code=500 Internal Server Error
Reply With Quote
  #6  
Old 05-02-2006, 08:15 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,585
I am not exactly sure what is the problem, maybe support for your ruby script is poor. You can try the following hello.rb, if it works, please send us your testing script, we will figure out the problem.

Code:
#!/usr/local/bin/ruby

print "HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\nHello World!\r\n"
ENV.each_pair {|key, value| print "#{key} is #{value}
\r\n" }
Reply With Quote
  #7  
Old 05-02-2006, 08:24 PM
Xorlev Xorlev is offline
Senior Member
 
Join Date: Nov 2005
Posts: 58
Aha it works now with the script you gave me, however it appears your testcgi.rb script is malfunctioning on my setup, which was what "test.rb" was.
Reply With Quote
  #8  
Old 05-03-2006, 07:46 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,585
testcgi.rb itself is using LSAPI interface, it is for testing the ruby "cgi" extension under LSAPI. Itself is a LSAPI application, It will not work under the lsruby_runner.
Reply With Quote
  #9  
Old 05-03-2006, 12:37 PM
Xorlev Xorlev is offline
Senior Member
 
Join Date: Nov 2005
Posts: 58
Aha, I should have thought of that. :oops:

Thank you for your help, and out of curiousity how would I make LSAPI work directly from the script (ie, requiring it in then using the blocks given)? A context?
Reply With Quote
  #10  
Old 05-03-2006, 02:06 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,585
Yes, the extra code for LSAPI is pretty simple.
You need to define a LSAPI application for each LSAPI ruby script, then mount the application via a context or script handler.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setup for Rails via Litespeed Ruby LSAPI Justin Ruby/Rails 2 12-08-2007 07:19 PM
Ruby LSAPI 2.4 and PHP LSAPI 3.1 released mistwang News 0 04-24-2007 03:35 PM
Ruby LSAPI 1.13 Released mistwang News 0 01-16-2007 10:17 AM
LSAPI Ruby v1.12, PHP v2.4 Released mistwang News 0 01-10-2007 01:18 PM
LSWS Ruby LSAPI zoom Install/Configuration 2 05-14-2006 04:50 PM


All times are GMT -7. The time now is 09:57 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.