View Single Post
  #3  
Old 01-10-2008, 08:14 PM
zhesto zhesto is offline
Member
 
Join Date: Jun 2006
Posts: 11
What i've done until now:

1. Handler modified:

Code:
require 'lsapi'

module Rack
  module Handler
    class Litespeed
      def self.run(app, options=nil)
        while LSAPI.accept != nil
          serve app
        end
      end

      def self.serve(app)
        env = ENV
        ...
                     "rack.run_once" => false,
2. Handler added to the {rack_path}/lib/rack.rb:
Code:
module Handler
    autoload :CGI, "rack/handler/cgi"
    autoload :Litespeed, "rack/handler/litespeed"
    ...
  end
3. External application created:
Code:
Name	 			rbLsapi
Address	 			uds://tmp/lshttpd/lsruby.sock
Notes	 			Not Set
Max Connections 		5	
Environment	
				LSAPI_MAX_REQUESTS=500
				LSAPI_CHILDREN=5
Initial Request Timeout (secs)	180
Retry Timeout (secs)		0
Persistent Connection		Not Set
Connection Keepalive Timeout	Not Set
Response Buffering		No
Auto Start			Yes
Command				$SERVER_ROOT/fcgi-bin/lsruby_runner.rb
Back Log			50
Instances			1
Run On Start Up			Not Set
Max Idle Time			Not Set
Priority	 		3
Memory Soft Limit (bytes)	250M
Memory Hard Limit (bytes)	300M
Process Soft Limit		200
Process Hard Limit		200
4. Ruby scripts bound to the rbLsapi:
Code:
rb	LiteSpeed API	[Server Level]: rbLsapi
5. Simple script in $SERVER_ROOT/DEFAULT/html/simple.rb:
Code:
require 'rubygems'
require 'rack'
require 'lsapi'

class HelloWorld
  def call(env)
    [ 200, # HTTP Response Code
      { "Content-Type"=>"text/plain" }, # HTTP Headers
      [ "Hello, World!" ] # Body
    ]
  end
end

# Instantiate your app
app = HelloWorld.new

Rack::Handler::Litespeed.run app
The result: 500 Internal Server Error

In the error.log:
Code:
2008-01-11 12:54:47.088 [INFO] [rbLsapi] add child process pid: 3094
2008-01-11 12:54:47.088 [INFO] [rbLsapi] pid list size: 1
2008-01-11 12:54:47.218 [NOTICE] [192.168.3.81:54602-0#Example] Premature end of response header.
2008-01-11 12:55:03.555 [WARN] [192.168.3.81:54604-0#Example] LSAPI Packet header is invalid,('S','t','a','t','u','s',':',' ')
2008-01-11 12:55:03.555 [INFO] [192.168.3.81:54604-0#Example] connection to [uds://tmp/lshttpd/lsruby.sock] on request #0, error: Input/output error!
2008-01-11 12:55:03.555 [INFO] [uds://tmp/lshttpd/lsruby.sock] Connection error: Input/output error, adjust maximum connections to 4!
Reply With Quote