Must compare the variables in the method drb_process in sbsm/request.rb in the old mod_ruby to the variables calculated in the method call called by webrick/rack. With some logging to /var/www/steinwies.ch/log/request.log I get
==> log/request.log <== I, [2016-11-01T08:59:01.305262 #402] INFO -- : sbsm/request 69 pid 402 process @cgi.params languageendefault_flavor I, [2016-11-01T08:59:01.311992 #402] INFO -- : sbsm/request 166 pid 402 drb_process @session #<CGI::Session:0x7f398bcdf250 @dbman=#<CGI::Session::DRbSession:0x7f398bcdf098 @obj=#<DRb::DRbObject:0x7f398bcde1e8 @uri="druby://localhost:10001", @ref=20914540>>, @new_session=false, @session_id="2d451e8fe97c75aa8b06ef6537db5c51", @dbprot=[#<CGI::Session::DRbSession:0x7f398bcdf098 @obj=#<DRb::DRbObject:0x7f398bcde1e8 @uri="druby://localhost:10001", @ref=20914540>>]> I, [2016-11-01T08:59:01.313203 #402] INFO -- : sbsm/request 168 drb_process @proxy #<DRb::DRbObject:0x7f398bcdc618 @uri="druby://localhost:10001", @ref=20914540> ==> log/session.log <== I, [2016-11-01T08:59:01.313752 #325] INFO -- : 167: drb_process pid 325 DRb::DRbObject I, [2016-11-01T08:59:01.315354 #325] INFO -- : 358: process pid 325 DRb::DRbObject GET / Steinwies::Validator
Where the PID 325 belong to the Steinwies DRB-process and PID 402 is /usr/sbin/apache2.
Therefore I must ensure that in the call process I can find the correct @proxy = @session[:proxy], which is set inside the restore method of lib/sbsm /session. The code there is
def restore hash = {:proxy => self,} hash.extend(DRbUndumped) # added for Ruby1.8 compliance hash end
Adding a debug statement to see the callers.
Added a debug statement to see, by whom and when the session is stored in the DrbServer. It is done in the Steinwies Drb and outputs
pid 15942 drbserver add key 2d451e8fe97c75aa8b06ef6537db5c51 args ["2d451e8fe97c75aa8b06ef6537db5c51", nil] /usr/local/lib/ruby/2.3.0/delegate.rb:85:in `method_missing' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/drbserver.rb:155:in `block in []' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/drbserver.rb:149:in `synchronize' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/drbserver.rb:149:in `[]' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop'and in the corresponding session.log
I, [2016-11-01T10:21:15.427441 #15748] INFO -- : 358: process pid 15748 DRb::DRbObject GET /en/page/schwerpunkte/ Steinwies::Validator I, [2016-11-01T10:23:45.032340 #15942] INFO -- : 495: restore pid 15942 /usr/local/lib/ruby/2.3.0/delegate.rb:85:in `method_missing' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/session.rb:495:in `restore' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop' I, [2016-11-01T10:23:45.034249 #15942] INFO -- : 167: drb_process pid 15942 DRb::DRbObject I, [2016-11-01T10:23:45.036078 #15942] INFO -- : 358: process pid 15942 DRb::DRbObject GET /en/page/person/ Steinwies::Validator
Added a debug to see, where the CGI::DrbSession is created.
I, [2016-11-01T11:22:29.380635 #22307] INFO -- : request.rb:67:in `process' @cgi.params zonepagelanguageeneventpersondefault_flavor I, [2016-11-01T11:22:29.382710 #22231] INFO -- : drbserver.rb:156:in `block in []' add key 2d451e8fe97c75aa8b06ef6537db5c51 args ["2d451e8fe97c75aa8b06ef6537db5c51", nil] /usr/local/lib/ruby/2.3.0/delegate.rb:85:in `method_missing' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/drbserver.rb:156:in `block in []' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/drbserver.rb:150:in `synchronize' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/drbserver.rb:150:in `[]' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop' I, [2016-11-01T11:22:29.390914 #22307] INFO -- : drbsession.rb:20:in `initialize' uri druby://localhost:10001 holder session-id /usr/local/bin/ruby186/lib/ruby/1.8/cgi/session.rb:274:in `new' /usr/local/bin/ruby186/lib/ruby/1.8/cgi/session.rb:274:in `initialize' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/request.rb:163:in `new' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/request.rb:163:in `drb_process' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/request.rb:68:in `process' /var/www/steinwies.ch/doc/index.rbx:9 /usr/local/bin/ruby186/lib/ruby/1.8/apache/ruby-run.rb:53:in `load' /usr/local/bin/ruby186/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler' I, [2016-11-01T11:22:29.391745 #22307] INFO -- : request.rb:164:in `drb_process' @session #<CGI::Session:0x7fa35e1284b0 @session_id="2d451e8fe97c75aa8b06ef6537db5c51", @dbprot=[#<CGI::Session::DRbSession:0x7fa35e1282f8 @obj=#<DRb::DRbObject:0x7fa35e125440 @uri="druby://localhost:10001", @ref=28400700>>], @dbman=#<CGI::Session::DRbSession:0x7fa35e1282f8 @obj=#<DRb::DRbObject:0x7fa35e125440 @uri="druby://localhost:10001", @ref=28400700>>, @new_session=false> I, [2016-11-01T11:22:29.391842 #22307] INFO -- : drbsession.rb:25:in `restore' caller is /usr/local/bin/ruby186/lib/ruby/1.8/cgi/session.rb:306:in `[]' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/request.rb:165:in `drb_process' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/request.rb:68:in `process' /var/www/steinwies.ch/doc/index.rbx:9 /usr/local/bin/ruby186/lib/ruby/1.8/apache/ruby-run.rb:53:in `load' /usr/local/bin/ruby186/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler' I, [2016-11-01T11:22:29.392457 #22231] INFO -- : session.rb:493:in `restore' 493: restore pid 22231 /usr/local/lib/ruby/2.3.0/delegate.rb:85:in `method_missing' /var/www/steinwies.ch/vendor/ruby/2.3.0/gems/sbsm-1.3.0/lib/sbsm/session.rb:493:in `restore' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1624:in `perform_without_block' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1584:in `perform' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1657:in `block (2 levels) in main_loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `loop' /usr/local/lib/ruby/2.3.0/drb/drb.rb:1653:in `block in main_loop' I, [2016-11-01T11:22:29.393413 #22307] INFO -- : request.rb:166:in `drb_process' @proxy #<DRb::DRbObject:0x7fa35e122fd8 @uri="druby://localhost:10001", @ref=28400700> I, [2016-11-01T11:22:29.394091 #22231] INFO -- : session.rb:165:in `drb_process' request DRb::DRbObject I, [2016-11-01T11:22:29.395768 #22231] INFO -- : session.rb:356:in `process' DRb::DRbObject GET /en/page/person/ Steinwies::Validator
I think that is the missing piece. It comes for doc/index.rb, where the SBSM:Request ist generated via SBSM::Request.new(Steinwies.config.server_uri).process
. This is something I did not yet do inside the implementation of the call method.
Okay. I think I must make the following sequence work in call after Rack::Respons.new
@drb_uri = SERVER_URI args = { 'database_manager' => CGI::Session::DRbSession, 'drbsession_uri' => @drb_uri, 'session_path' => '/', } @cgi = CGI.initialize_without_offline_prompt('html4') @session = CGI::Session.new(@cgi, args) @proxy = @session[:proxy] res = @proxy.drb_process(self)
Also changed creating the session_id to session_id = rand(BIGNUM_MAX*10240000000000).to_s(16))
to have a similar ID than before.
Committing changes.
Not it is time to move the call method from the steinwies/simple_sbsm.rb to a class in SBSM. Now it is easy to make progress. When visiting http://localhost:8998/test/path I return now
State is Home pid is 32055 request_path is /test/path @member_counter is 1 @@class_counter is 2
Minimized simple_sbsm.rb to not reference html_grid and elmininating unneeded stuff. File is down now to 67 lines, which is pretty cool.
Pushed commits
Now I must made the unit test pass again. Got rid of the file lib/sbsm/cgi.rb
by adding
Could get rid of another 5 lines in simple_sbsm.rb of steinwies. See commit
Made unit test (except test_application) pass. test_application has now an error message I don't understand on how to silence it. It stems from the fact that I use the Rack::Tests methods, which seem to mock a CGI::Session in an incompatible way for me. The error pops up like
ArgumentError: wrong number of arguments (given 2, expected 0) /home/niklaus/git/sbsm/lib/sbsm/app.rb:111:in `initialize' /home/niklaus/git/sbsm/lib/sbsm/app.rb:111:in `new' /home/niklaus/git/sbsm/lib/sbsm/app.rb:111:in `call'
But the Steinwies simple_sbsm app has no problem. Therefore pushed commits:
Will look tommorrow on howto make the complete steinwies app working.
Pushed commit Ignore errors in Ruby 2.2