Uploaded image for project: 'TorqueBox'
  1. TorqueBox
  2. TORQUE-44

TorqueBox does not pass settings from myapp-rack.yml to Merb and Sinatra

    Details

    • Workaround Description:
      Hide

      For Sinatra, add set(:environment, :production) to config.ru. For Merb, set Merb::Config[:merb_root], Merb::Config[:environment] , Merb::Config[:environment] and Merb::Config[:path_prefix] variables in config.ru.

      Show
      For Sinatra, add set(:environment, :production) to config.ru. For Merb, set Merb::Config [:merb_root] , Merb::Config [:environment] , Merb::Config [:environment] and Merb::Config [:path_prefix] variables in config.ru.
    • Estimated Difficulty:
      Medium

      Description

      RACK PROBLEMS
      =============

      SINATRA

      1. file $TORQUEBOX_HOME/jboss/server/web/deploy/sinatra1-rack.yml:

      application:
      RACK_ROOT: /Volumes/300GB/TorqueBox/myapps/sinatra1

      1. this variable is not visible in Sinatra
      2. RACK_ENV: production

      rackup: config.ru

      1. it also not visible in Sinatra
        #context: /sinatra1

      Issues:

      RACK_ROOT, RACK_ENV and context variables are ignored in Sinatra. ENV is empty and Object.constants does not contain any of them. And because RACK_ENV is empty Sinatra starts always in development mode (vide: http://www.sinatrarb.com/configuration.html). It can be solved by adding the following line to config.ru (just before "run Sinatra::Application" line): set:environment, :production

      Instead of using 'context' variable, TorqueBox takes it from RACK_ROOT line (of sinatra1-rack.yml file). The last part will be recognized as the context.
      E.g. for RACK_ROOT: /Volumes/300GB/TorqueBox/myapps/sinatra1 'context' will be 'sinatra1'.

      Name of the file $TORQUEBOX_HOME/jboss/server/web/deploy/sinatra1-rack.yml does not matter (buy it matters for Merb!)

      So for Sinatra config.ru can be reduced to

      application:
      RACK_ROOT: /Volumes/300GB/TorqueBox/myapps/sinatra1
      rackup: config.ru

      MERB

      1. $TORQUEBOX_HOME/jboss/server/web/deploy/merb1-rack.yml
        application:
        RACK_ROOT: /Volumes/300GB/TorqueBox/myapps/merb1
        RACK_ENV: production
        rackup: config.ru
        web:
        context: /merb1

      Issues

      RACK_ROOT, RACK_ENV and context variables are not visible in Merb. ENV is also empty and Object.constants does not contain them.

      1. $TORQUEBOX_HOME/jboss/server/web/deploy/merb1-rack.yml
        require 'merb-core'
        cfg = { # It has to be set because File.expand_path(File.dirname(__FILE__)) # instead of /Volumes/300GB/TorqueBox/myapps/merb1 points to # wrong place: $TORQUEBOX_HOME/jboss/RubyRackApplication :merb_root => '/Volumes/300GB/TorqueBox/myapps/merb1', # hast to be set because ENV['RACK_ENV'] is not available :environment => 'production', # has to be set because 'context' from merb1-rack.yml is not available :path_prefix => '/merb1' }


        Merb::Config.setup(cfg)
        Merb.environment = Merb::Config[:environment]
        Merb.root = Merb::Config[:merb_root]
        if prefix = Merb::Config[:path_prefix]
        use Merb::Rack::PathPrefix, prefix
        end
        Merb::BootLoader.run
        run Merb::Rack::Application.new

      RAILS

      Rails works fine. Variables set in $TORQUEBOX_HOME/jboss/server/web/deploy/rails1-rails.yml are available in Object.constants in Rails. E.g. context is available as TORQUEBOX_RACKUP_CONTEXT. ENV is empty.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                hipertracker Jaroslaw Zabiello
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: