Awhile back I upgraded the “rack” gem on one of our CentOS Linux servers that runs LiteSpeed and Ruby. The upgrade took the rack gem from rack version 1.0.0 to rack version 1.0.1. After upgrading the Rack gem I attempted to visit the site located on the server where the gem was updated only to receive a 503 error from LiteSpeed. During the troubleshooting process I looked at the LiteSpeed error logs and noticed errors that lead me back to the Rack gem I had just updated. Below I describe the error in more detail and what can be done to resolve the issue of rack-1.0.1.
LiteSpeed Log Errors Caused By Rack Gem Upgrade:
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] /home/web/devredmine/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in `const_missing'
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] :
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] uninitialized constant Rack::Handler::LSWS::RewindableInput
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] (
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] NameError
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] )
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] from /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/lsws.rb:19:in `serve'
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] from /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/lsws.rb:9:in `run'
- 2010-03-30 16:44:38.567 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] from /var/lsws/fcgi-bin/RailsRunner.rb:61
- 2010-03-30 16:44:38.706 [INFO] [192.168.222.33:6386-1#devredmine.example.com] connection to [/tmp/lshttpd/devredmine.example.com:_.sock.460] on request #0, confirmed, 1, associated process: 27675, running: 1, error: Connection reset by peer!
- 2010-03-30 16:44:38.749 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] /home/web/devredmine/vendor/rails/activesupport/lib/active_support/dependencies.rb:105:in `const_missing'
- 2010-03-30 16:44:38.750 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] :
- 2010-03-30 16:44:38.750 [NOTICE] [192.168.222.33:6386-1#devredmine.example.com] [STDERR] uninitialized constant Rack::Handler::LSWS::RewindableInput
Resolve Rack Version 1.0.1 Gem Errors:
As you can see in the above log entries the error deals with “Rack Handler LSWS RewindableInput”. After some research I happened upon some posts on the LiteSpeed forums that pointed me in the direction of a slight modification to one of the files installed with the rack gem. Below are the details of that modification that resolved the issue with rack-1.0.1. The file that needs to be modified is typically installed in the “/usr/local/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler” directory however if rubygems was installed in a different manner than the default way on CentOS the directory could have a different path. If that is the case simply find the gems directory and then drill down into the “rack-1.1.0/lib/rack/handler” directory. The file we are going to be modifying is the lsws.rb file which is located in that handler directory underneath the rack gem directory structure.
Original Rack Gem lsws.rb File Line 19:
- rack_input = RewindableInput.new($stdin.read.to_s)
New Rack Gem lsws.rb File Line 19:
- rack_input = StringIO.new($stdin.read.to_s)
- env.update(
- "rack.version" => [1,0],
- "rack.input" => rack_input,
- "rack.errors" => $stderr,
- "rack.multithread" => false,
- "rack.multiprocess" => true,
- "rack.run_once" => false,
- "rack.url_scheme" => ["yes", "on", "1"].include?(ENV["HTTPS"]) ? "https" : "http"
- )
After modifying the lsws.rb file and restarting LiteSpeed everything functioned properly.