Class: GlassFish::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, &block) ⇒ Server

Returns a new instance of Server.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/server.rb', line 61

def initialize(args, &block)

  unless args[:log_level].nil?
    if args[:log_level] > 4
      puts "Arguments: "
      args.each do |k, v|
        puts "\t#{k}=>#{v}"
      end
    end

    if args[:log_level] > 3
      debug = true
    end

  end

  java.lang.System.getProperties().put("jruby.runtime", JRuby.runtime) unless args[:daemon]

  @opts = Options.new
  @opts.runtimes = args[:runtimes]
  @opts.runtimes_min = args[:runtimes_min]
  @opts.runtimes_max = args[:runtimes_max]
  @opts.environment = args[:environment]
  @opts.port = args[:port]
  @opts.address = args[:address]
  @opts.contextRoot = args[:contextroot]
  @opts.appDir = args[:app_dir]
  @opts.daemon = args[:daemon]
  @opts.pid = args[:pid]
  @opts.log = args[:log]
  @opts.log_console = args[:log_console]
  @opts.domainDir = args[:domain_dir]
  @opts.log_level = args[:log_level]
  @opts.jvm_opts = args[:jvm_options]


  unless args[:grizzly_config].nil?
    args[:grizzly_config].each do |key, val|
      case key
        when "chunking-enabled"
          @opts.grizzlyConfig.chunkingEnabled = val unless val.nil?
        when "request-timeout"
          @opts.grizzlyConfig.requestTimeout = val unless val.nil?
        when "send-buffer-size"
          @opts.grizzlyConfig.sendBufferSize = val unless val.nil?
        when "max-keepalive-connextions"
          @opts.grizzlyConfig.maxKeepaliveConnections = val unless val.nil?
        when "keepalive-timeout"
          @opts.grizzlyConfig.keepaliveTimeout = val unless val.nil?
        when "thread-pool"
          unless val.nil?
            val.each do |k, v|
              case k
                when "idle-thread-timeout-seconds"
                  @opts.grizzlyConfig.threadPool.idleThreadTimeoutSeconds = v unless v.nil?
                when "max-queue-size"
                  @opts.grizzlyConfig.threadPool.maxQueueSize = v unless v.nil?
                when "max-thread-pool-size"
                  @opts.grizzlyConfig.threadPool.maxThreadPoolSize = v unless v.nil?
                when "min-thread-pool-size"
                  @opts.grizzlyConfig.threadPool.minThreadPoolSize = v unless v.nil?
              end
            end
          end
      end
    end
  end

  #Create the app using Rack builder
  if(block)
    app = Rack::Builder.new(&block).to_app
    app = Rack::CommonLogger.new(@app) if debug
    if app.nil?
      app = block
    end
    @opts.app = app;

    java.lang.System.getProperties().put("glassfish.rackupApp", app)
  end
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



59
60
61
# File 'lib/server.rb', line 59

def opts
  @opts
end

Class Method Details

.start(args, &block) ⇒ Object



142
143
144
145
146
147
# File 'lib/server.rb', line 142

def self.start(args, &block)
  #Validate the command line options
  args = GlassFish::Config.init_opts.merge! args
  Config.new.validate! args
  new(args, &block).start!
end

Instance Method Details

#nameObject Also known as: to_s



158
159
160
# File 'lib/server.rb', line 158

def name
  "GlassFish v3 server"
end

#startObject Also known as: start!



149
150
151
# File 'lib/server.rb', line 149

def start
  GlassFishMain.start @opts
end

#stopObject



154
155
156
# File 'lib/server.rb', line 154

def stop
  GlassFishMain.start @opts
end