glassfish 0.9.5-universal-java → 1.0.0-universal-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +247 -0
- data/LICENSE.txt +774 -0
- data/README.txt +140 -0
- data/bin/gfrake +5 -1
- data/bin/glassfish +5 -7
- data/generators/gfrake/templates/glassfish.yml +39 -0
- data/lib/command_line_parser.rb +29 -40
- data/lib/config.rb +57 -63
- data/lib/glassfish.rb +3 -79
- data/{modules → lib/java}/akuma.jar +0 -0
- data/lib/java/gf-jruby-connector.jar +0 -0
- data/lib/java/glassfish-embedded-nucleus.jar +0 -0
- data/lib/java/glassfish-gem.jar +0 -0
- data/lib/java/grizzly-jruby-module.jar +0 -0
- data/lib/java/grizzly-jruby.jar +0 -0
- data/lib/jruby/rack/grizzly_helper.rb +230 -0
- data/lib/jruby/rack/merb.rb +34 -0
- data/lib/jruby/rack/rackup.rb +46 -0
- data/lib/jruby/rack/rails.rb +29 -0
- data/lib/jruby/rack/sinatra.rb +18 -0
- data/lib/jruby/rails_path.rb +11 -0
- data/lib/{templates/profile.properties → rack/adapter/merb.rb} +18 -7
- data/lib/rack/adapter/rails.rb +268 -0
- data/lib/rack/handler/grizzly.rb +59 -0
- data/lib/server.rb +164 -0
- data/lib/version.rb +1 -1
- metadata +83 -153
- data/bin/glassfish_rails +0 -61
- data/config/asadminenv.conf +0 -6
- data/config/asenv.bat +0 -29
- data/config/asenv.conf +0 -31
- data/config/glassfish.container +0 -4
- data/domains/domain1/config/admin-keyfile +0 -3
- data/domains/domain1/config/cacerts.jks +0 -0
- data/domains/domain1/config/default-web.xml +0 -1133
- data/domains/domain1/config/domain-passwords +0 -0
- data/domains/domain1/config/domain.xml +0 -190
- data/domains/domain1/config/glassfish_gem_version.yml +0 -7
- data/domains/domain1/config/keyfile +0 -6
- data/domains/domain1/config/keystore.jks +0 -0
- data/domains/domain1/config/logging.properties +0 -46
- data/domains/domain1/config/login.conf +0 -21
- data/domains/domain1/config/server.policy +0 -170
- data/domains/domain1/config/sun-acc.xml +0 -40
- data/domains/domain1/docroot/index.html +0 -83
- data/domains/domain1/master-password +0 -0
- data/lib/appclient/appclientlogin.conf +0 -10
- data/lib/appclient/client.policy +0 -79
- data/lib/appclient/wss-client-config-1.0.xml +0 -84
- data/lib/appclient/wss-client-config-2.0.xml +0 -96
- data/lib/registration/servicetag-registry.xml +0 -18
- data/lib/templates/cacerts.jks +0 -0
- data/lib/templates/default-web.xml +0 -1133
- data/lib/templates/docroot/index.html +0 -83
- data/lib/templates/domain.xml +0 -180
- data/lib/templates/domain.xml.xsl +0 -100
- data/lib/templates/keyfile +0 -6
- data/lib/templates/keystore.jks +0 -0
- data/lib/templates/logging.properties +0 -48
- data/lib/templates/login.conf +0 -21
- data/lib/templates/server.policy +0 -170
- data/lib/templates/sun-acc.xml +0 -40
- data/modules/admin-cli.jar +0 -0
- data/modules/api-exporter.jar +0 -0
- data/modules/asm-all-repackaged.jar +0 -0
- data/modules/auto-depends.jar +0 -0
- data/modules/bean-validator.jar +0 -0
- data/modules/branding.jar +0 -0
- data/modules/cli-framework.jar +0 -0
- data/modules/common-util.jar +0 -0
- data/modules/config-api.jar +0 -0
- data/modules/config.jar +0 -0
- data/modules/deployment-admin.jar +0 -0
- data/modules/deployment-autodeploy.jar +0 -0
- data/modules/deployment-common.jar +0 -0
- data/modules/flashlight-agent.jar +0 -0
- data/modules/flashlight-framework.jar +0 -0
- data/modules/gf-jruby-connector.jar +0 -0
- data/modules/gfprobe-provider-client.jar +0 -0
- data/modules/glassfish-api.jar +0 -0
- data/modules/glassfish-ee-api.jar +0 -0
- data/modules/glassfish-extra-jre-packages.jar +0 -0
- data/modules/glassfish-gem.jar +0 -0
- data/modules/glassfish.jar +0 -0
- data/modules/grizzly-comet.jar +0 -0
- data/modules/grizzly-cometd.jar +0 -0
- data/modules/grizzly-compat.jar +0 -0
- data/modules/grizzly-config.jar +0 -0
- data/modules/grizzly-framework.jar +0 -0
- data/modules/grizzly-http.jar +0 -0
- data/modules/grizzly-jruby-module.jar +0 -0
- data/modules/grizzly-jruby.jar +0 -0
- data/modules/grizzly-messagesbus.jar +0 -0
- data/modules/grizzly-portunif.jar +0 -0
- data/modules/grizzly-rcm.jar +0 -0
- data/modules/grizzly-utils.jar +0 -0
- data/modules/hk2-core.jar +0 -0
- data/modules/hk2.jar +0 -0
- data/modules/internal-api.jar +0 -0
- data/modules/kernel.jar +0 -0
- data/modules/launcher.jar +0 -0
- data/modules/org.apache.felix.configadmin.jar +0 -0
- data/modules/org.apache.felix.fileinstall.jar +0 -0
- data/modules/org.apache.felix.shell.jar +0 -0
- data/modules/org.apache.felix.shell.remote.jar +0 -0
- data/modules/org.apache.felix.shell.tui.jar +0 -0
- data/modules/osgi-main.jar +0 -0
- data/modules/pkg-client.jar +0 -0
- data/modules/tiger-types-osgi.jar +0 -0
data/README.txt
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
= GlassFish v3 server for Rack based web frameworks (Rails, Merb, ...)
|
2
|
+
|
3
|
+
GlassFish gem is a lightweight and robust deployment solution for
|
4
|
+
Ruby on Rails applications deployed on JRuby runtime. It is based
|
5
|
+
on GlassFish v3 application server.
|
6
|
+
|
7
|
+
GlassFish v3 is a Java based application server that allows deployment,
|
8
|
+
administration and monitoring of JavaEE as well as dynamic languages based web
|
9
|
+
frameworks such as Ruby On Rails, Grails etc.
|
10
|
+
|
11
|
+
GlassFish gem is based on GlassFish v3 nucleus. GlassFish v3 nucleus is the core module of GlassFish v3.
|
12
|
+
|
13
|
+
For more information on GlassFish v3 application server see GlassFish project page[https://glassfish.dev.java.net/].
|
14
|
+
|
15
|
+
== Requires JDK 6
|
16
|
+
Get JDK 6 from here[http://java.sun.com/javase/downloads/index.jsp]
|
17
|
+
|
18
|
+
== Supported Rack based frameworks
|
19
|
+
|
20
|
+
* Rails
|
21
|
+
* Merb
|
22
|
+
* Sinatra
|
23
|
+
|
24
|
+
=== Getting Started
|
25
|
+
|
26
|
+
1. Install the gem: <tt>gem install glassfish</tt>.
|
27
|
+
2. Run glassfish in the top directory of your Rails or Merb application:
|
28
|
+
|
29
|
+
$glassfish
|
30
|
+
|
31
|
+
=== Usage
|
32
|
+
|
33
|
+
GlassFish gem's +glassfish+ command autodetects the application you trying to
|
34
|
+
run on it. Internally it uses Grizzly handler to plugin to Rack interface of
|
35
|
+
the application frameworks such as Rails, Merb or Sinatra.
|
36
|
+
|
37
|
+
$ glassfish
|
38
|
+
|
39
|
+
That's all you need to run your application.
|
40
|
+
|
41
|
+
$glassfish -h
|
42
|
+
|
43
|
+
===Synopsis
|
44
|
+
|
45
|
+
glassfish: GlassFish v3 server for Rack based frameworks such as: Rails,
|
46
|
+
Merb, Sinatra...
|
47
|
+
|
48
|
+
===Usage:
|
49
|
+
|
50
|
+
glassfish [OPTION] APPLICATION_PATH
|
51
|
+
|
52
|
+
-h, --help: show help
|
53
|
+
|
54
|
+
-c, --contextroot PATH: change the context root (default: '/')
|
55
|
+
|
56
|
+
-p, --port PORT: change server port (default: 3000)
|
57
|
+
|
58
|
+
-a, --address HOST: bind to HOST address (default: 0.0.0.0)
|
59
|
+
|
60
|
+
-e, --environment ENV: change rails environment (default: development)
|
61
|
+
|
62
|
+
-n --runtimes NUMBER: Number of JRuby runtimes to create initially
|
63
|
+
|
64
|
+
--runtimes-min NUMBER: Minimum JRuby runtimes to create
|
65
|
+
|
66
|
+
--runtimes-max NUMBER: Maximum number of JRuby runtimes to create
|
67
|
+
|
68
|
+
-d, --daemon: Run GlassFish as daemon. Currently works with
|
69
|
+
Linux and Solaris OS.
|
70
|
+
|
71
|
+
-P, --pid FILE: PID file where PID will be written. Applicable
|
72
|
+
when used with -d option. The default pid file
|
73
|
+
is tmp/pids/glassfish-<PID>.pid
|
74
|
+
|
75
|
+
-l, --log FILE: Log file, where the server log messages will go.
|
76
|
+
By default the server logs go to
|
77
|
+
log/development.log file. To see the logs on
|
78
|
+
console run with -l option without any argument.
|
79
|
+
|
80
|
+
--log-level LEVEL: Log level 0 to 7. 0:OFF, 1:SEVERE, 2:WARNING,
|
81
|
+
3:INFO (default), 4:FINE, 5:FINER, 6:FINEST,
|
82
|
+
7:ALL.
|
83
|
+
|
84
|
+
--config FILE: Configuration file location. Use glassfish.yml
|
85
|
+
as template. Generate it using 'gfrake config'
|
86
|
+
command.
|
87
|
+
|
88
|
+
APPLICATION_PATH (optional): Path to the application to be run (default:
|
89
|
+
current).
|
90
|
+
|
91
|
+
For further configuration, run GlassFish rake command 'gfrake -T'
|
92
|
+
|
93
|
+
===Configuration
|
94
|
+
|
95
|
+
$gfrake -T
|
96
|
+
|
97
|
+
rake clean # Clean GlassFish generated temporary files (tmp/.glassfish)
|
98
|
+
rake config # Generate a configuration file to customize GlassFish gem
|
99
|
+
rake version # Display version of GlassFish gem
|
100
|
+
|
101
|
+
<b>Note:</b> Although help screen shows rake command. You need to use gfrake instead.
|
102
|
+
|
103
|
+
* <tt>gfrake config</tt> will place <b>glassfish.yml</b> in the application's config directory. <b>glassfish.yml</b> contains default options. Use it as template. You can also use <tt>--config</tt> option with the <tt>glassfish</tt> command
|
104
|
+
|
105
|
+
=== Application auto-detection
|
106
|
+
|
107
|
+
Rails, Merb and Sinatra applications are detected automatically and configured appropriately. You can provide a rack-up script <tt>*.ru</tt> in to the application directory to plugin any other framework.
|
108
|
+
|
109
|
+
Some key points:
|
110
|
+
|
111
|
+
* Rails version < 2.2 is single threaded, for improved scaling you can
|
112
|
+
configure the JRuby runtime pool using <tt>--runtimes, --runtimes-min or
|
113
|
+
--runtimes-max</tt> options.
|
114
|
+
* Multi-thread-safe execution (as introduced in Rails 2.2 or for Merb) is
|
115
|
+
detected and runtime pooling is disabled. You would still need to tell Rails
|
116
|
+
to enable multi-threading by commenting out the following line from
|
117
|
+
<tt>config/environments/production.rb</tt>.
|
118
|
+
|
119
|
+
<tt>#config.threadsafe!</tt>
|
120
|
+
|
121
|
+
Or you can simply call config.threadsafe! form any Rails initialization
|
122
|
+
script.
|
123
|
+
|
124
|
+
=== Known Issues
|
125
|
+
|
126
|
+
* Running <tt>glassfish</tt> in a directory that is neither a Rails or Merb
|
127
|
+
application does not report a meaningful error.
|
128
|
+
See this issue[https://glassfish.dev.java.net/issues/show_bug.cgi?id=6744]
|
129
|
+
|
130
|
+
|
131
|
+
=== Source
|
132
|
+
|
133
|
+
You can get the GlassFish source using svn, in any of the following ways:
|
134
|
+
|
135
|
+
<tt>svn co https://svn.dev.java.net/svn/glassfish-scripting/trunk/rails/gem</tt>
|
136
|
+
|
137
|
+
=== License
|
138
|
+
|
139
|
+
GlassFish v3 gem is provided with CDDL 1.0 and GPL 2.0 dual license. For
|
140
|
+
details see https://glassfish.dev.java.net/public/CDDL+GPL.html.
|
data/bin/gfrake
CHANGED
@@ -48,7 +48,11 @@ application.standard_exception_handling do
|
|
48
48
|
puts "(file #{GlassFish::Config::FILE} already exists. Pass argument FORCE=1 to override)"
|
49
49
|
elsif !File.directory?("config")
|
50
50
|
puts "(directory 'config' is missing)"
|
51
|
-
else
|
51
|
+
else
|
52
|
+
if File.exists?(GlassFish::Config::FILE) #FORCE=1
|
53
|
+
puts "(Backing up #{GlassFish::Config::FILE}.)"
|
54
|
+
cp GlassFish::Config::FILE, GlassFish::Config::FILE+".bak"
|
55
|
+
end
|
52
56
|
cp "#{GlassFish::HOME}/generators/gfrake/templates/glassfish.yml", GlassFish::Config::FILE
|
53
57
|
end
|
54
58
|
end
|
data/bin/glassfish
CHANGED
@@ -15,6 +15,9 @@
|
|
15
15
|
# -p, --port PORT::
|
16
16
|
# change server port (default: 3000)
|
17
17
|
#
|
18
|
+
# -a, --address HOST::
|
19
|
+
# bind to HOST address (default: 0.0.0.0)
|
20
|
+
#
|
18
21
|
# -e, --environment ENV::
|
19
22
|
# change rails environment (default: development)
|
20
23
|
#
|
@@ -46,13 +49,8 @@
|
|
46
49
|
#
|
47
50
|
# For further configuration, run GlassFish rake command 'gfrake -T'
|
48
51
|
|
49
|
-
require "java"
|
50
|
-
$LOAD_PATH << "#{File.dirname(__FILE__)}/../modules"
|
51
|
-
$LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
|
52
|
-
|
53
|
-
require 'command_line_parser'
|
54
52
|
require 'glassfish'
|
55
53
|
|
56
54
|
options = GlassFish::CommandLineParser.new.parse
|
57
|
-
|
58
|
-
|
55
|
+
GlassFish::Server.start options
|
56
|
+
|
@@ -13,10 +13,49 @@ http:
|
|
13
13
|
|
14
14
|
# port
|
15
15
|
port: 3000
|
16
|
+
|
17
|
+
#address
|
18
|
+
address: 0.0.0.0
|
16
19
|
|
17
20
|
# context root. The default value is '/'
|
18
21
|
contextroot: /
|
19
22
|
|
23
|
+
# Grizzly is NIO based HTTP libraries used by GlassFish gem
|
24
|
+
grizzly:
|
25
|
+
#HTTP chunking enable/disable
|
26
|
+
chunking-enabled: true
|
27
|
+
|
28
|
+
# Time after which the request times out in seconds
|
29
|
+
request-timeout: 30
|
30
|
+
|
31
|
+
#Send buffer size
|
32
|
+
send-buffer-size: 8192
|
33
|
+
|
34
|
+
#maximum number of keep-alive connections
|
35
|
+
max-keepalive-connextions: 256
|
36
|
+
|
37
|
+
#Keep Alive timeout, max time a connection can be deemed as idle and kept
|
38
|
+
#in the keep-alive state
|
39
|
+
keepalive-timeout: 30
|
40
|
+
|
41
|
+
#http thread pool used by Grizzly
|
42
|
+
thread-pool:
|
43
|
+
#Idle threads are removed from pool, after this time (in seconds)
|
44
|
+
idle-thread-timeout-seconds: 900
|
45
|
+
|
46
|
+
#The maxim number of tasks, which could be queued on the thread pool.
|
47
|
+
#-1 disables any maximum checks.
|
48
|
+
max-queue-size: 4096
|
49
|
+
|
50
|
+
#Maximum number of threads in the threadpool servicing
|
51
|
+
#requests in this queue. This is the upper bound on the no. of
|
52
|
+
#threads that exist in the threadpool.
|
53
|
+
max-thread-pool-size: 5
|
54
|
+
|
55
|
+
#Minimum number of threads in the threadpool servicing
|
56
|
+
#requests in this queue. These are created up front when this
|
57
|
+
#threadpool is instantiated
|
58
|
+
min-thread-pool-size: 2
|
20
59
|
|
21
60
|
#Logging configuration
|
22
61
|
log:
|
data/lib/command_line_parser.rb
CHANGED
@@ -45,33 +45,18 @@ require 'java'
|
|
45
45
|
#
|
46
46
|
module GlassFish
|
47
47
|
class CommandLineParser
|
48
|
+
attr_accessor :config
|
48
49
|
|
49
|
-
def init_opts
|
50
|
-
@@config ||= {
|
51
|
-
:runtimes => 1,
|
52
|
-
:runtimes_min => 1,
|
53
|
-
:runtimes_max => 1,
|
54
|
-
:contextroot => '/',
|
55
|
-
:environment => "development",
|
56
|
-
:app_dir => Dir.pwd,
|
57
|
-
:port => 3000,
|
58
|
-
:pid => nil,
|
59
|
-
:log => nil,
|
60
|
-
:log_console => false,
|
61
|
-
:log_level => 3,
|
62
|
-
:daemon => false,
|
63
|
-
:jvm_options => nil
|
64
|
-
}
|
65
|
-
end
|
66
50
|
|
67
51
|
def parse
|
68
|
-
|
52
|
+
|
69
53
|
check_java
|
70
54
|
|
71
|
-
config = init_opts
|
72
|
-
|
55
|
+
@config = Config.init_opts
|
56
|
+
|
73
57
|
opts = GetoptLong.new(
|
74
58
|
[ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
59
|
+
[ '--address', '-a', GetoptLong::REQUIRED_ARGUMENT ],
|
75
60
|
[ '--environment', '-e', GetoptLong::REQUIRED_ARGUMENT ],
|
76
61
|
[ '--contextroot', '-c', GetoptLong::REQUIRED_ARGUMENT ],
|
77
62
|
[ '--config', GetoptLong::REQUIRED_ARGUMENT ],
|
@@ -86,7 +71,7 @@ module GlassFish
|
|
86
71
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
87
72
|
)
|
88
73
|
|
89
|
-
config_file = File.join(config[:app_dir], "config", "glassfish.yml")
|
74
|
+
config_file = File.join(config[:app_dir], "config", "glassfish.yml")
|
90
75
|
opts.each do |opt, arg|
|
91
76
|
case opt
|
92
77
|
when '--version'
|
@@ -97,6 +82,8 @@ module GlassFish
|
|
97
82
|
RDoc::usage
|
98
83
|
when '--contextroot'
|
99
84
|
config[:contextroot] = arg
|
85
|
+
when '--address'
|
86
|
+
config[:address] = arg
|
100
87
|
when '--port'
|
101
88
|
config[:port] = arg.to_i
|
102
89
|
when '--environment'
|
@@ -127,21 +114,18 @@ module GlassFish
|
|
127
114
|
|
128
115
|
|
129
116
|
config[:app_dir] = ARGV.shift unless ARGV.empty?
|
130
|
-
|
117
|
+
|
131
118
|
#Read the config file from config/glasfish.yml
|
132
119
|
config_file = Config::absolutize config[:app_dir],config_file
|
133
120
|
read_glassfish_config(config_file, config)
|
134
121
|
|
135
|
-
#Validate the command line options
|
136
|
-
Config.new.validate config
|
137
|
-
|
138
122
|
config
|
139
123
|
|
140
124
|
end
|
141
125
|
|
142
126
|
private
|
143
127
|
|
144
|
-
# Read glassfish config file from config/glassfish.yml. CLI options will
|
128
|
+
# Read glassfish config file from config/glassfish.yml. CLI options will
|
145
129
|
# override the glassfish.yml configurations
|
146
130
|
def read_glassfish_config(cfile, config)
|
147
131
|
|
@@ -157,15 +141,20 @@ module GlassFish
|
|
157
141
|
case opt
|
158
142
|
when 'http'
|
159
143
|
val = arg['port']
|
160
|
-
|
161
|
-
|
162
|
-
|
144
|
+
config[:port] = val.to_i unless val.nil?
|
145
|
+
|
146
|
+
val = arg['address']
|
147
|
+
config[:address] = val unless val.nil?
|
163
148
|
|
164
149
|
val = arg['contextroot']
|
165
150
|
config[:contextroot] = val unless val.nil?
|
166
|
-
|
151
|
+
|
152
|
+
|
153
|
+
config[:grizzly_config] = arg['grizzly'] unless arg['grizzly'].nil?
|
154
|
+
|
155
|
+
when 'log'
|
167
156
|
val = arg['log-file']
|
168
|
-
|
157
|
+
unless val.nil?
|
169
158
|
config[:log] = Config::absolutize config[:app_dir], val
|
170
159
|
end
|
171
160
|
|
@@ -175,7 +164,7 @@ module GlassFish
|
|
175
164
|
config[:runtimes] = arg['initial'] unless arg['initial'].nil?
|
176
165
|
config[:runtimes_min] = arg['min'] unless arg['min'].nil?
|
177
166
|
config[:runtimes_max] = arg['max'] unless arg['max'].nil?
|
178
|
-
when 'daemon'
|
167
|
+
when 'daemon'
|
179
168
|
config[:daemon] = arg['enable'] unless arg['enable'].nil?
|
180
169
|
if(!arg['pid'].nil?)
|
181
170
|
if(!config[:daemon])
|
@@ -184,23 +173,23 @@ module GlassFish
|
|
184
173
|
config[:pid] = File.expand_path arg['pid']
|
185
174
|
end
|
186
175
|
end
|
187
|
-
|
176
|
+
|
188
177
|
#CLI option are overriden by glassfish.yml settings
|
189
178
|
if(!data['daemon'].nil? and (data['daemon'] or config[:daemon]))
|
190
|
-
config[:jvm_options] = arg['jvm-options'] unless arg['jvm-options'].nil?
|
179
|
+
config[:jvm_options] = arg['jvm-options'] unless arg['jvm-options'].nil?
|
191
180
|
else
|
192
181
|
STDERR.puts "Ignoring JVM options #{arg}. JVM options can only be passed in daemon mode. To use these, enable daemon mode"
|
193
|
-
end
|
182
|
+
end
|
194
183
|
when 'environment'
|
195
184
|
config[:environment] = arg unless arg.nil?
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
199
188
|
|
200
189
|
def check_java
|
201
|
-
begin
|
190
|
+
begin
|
202
191
|
java.lang.Class.forName("javax.xml.ws.Service")
|
203
|
-
rescue
|
192
|
+
rescue
|
204
193
|
#It is not Java6, fail
|
205
194
|
STDERR.puts "ERROR: You are running, Java version: "+java.lang.System.getProperty("java.version")+"."
|
206
195
|
STDERR.puts "ERROR: GlassFish gem needs Java ver. 6.0 or higher!"
|
data/lib/config.rb
CHANGED
@@ -45,17 +45,37 @@ module GlassFish
|
|
45
45
|
PID_FILE = Dir.pwd+File::SEPARATOR+"tmp"+File::SEPARATOR+"pids"+File::SEPARATOR+"glassfish"
|
46
46
|
DEFAULT_JVM_OPTS = "-server -Xmx512m -XX:MaxPermSize=192m -XX:NewRatio=2 -XX:+DisableExplicitGC -Dhk2.file.directory.changeIntervalTimer=6000";
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
def self.init_opts
|
49
|
+
{
|
50
|
+
:runtimes => 1,
|
51
|
+
:runtimes_min => 1,
|
52
|
+
:runtimes_max => 1,
|
53
|
+
:contextroot => '/',
|
54
|
+
:environment => "development",
|
55
|
+
:app_dir => Dir.pwd,
|
56
|
+
:port => 3000,
|
57
|
+
:address => "0.0.0.0",
|
58
|
+
:pid => nil,
|
59
|
+
:log => nil,
|
60
|
+
:log_console => false,
|
61
|
+
:log_level => 3,
|
62
|
+
:daemon => false,
|
63
|
+
:jvm_options => nil
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
# Validates the configuration options. If it can will revert to default else
|
69
|
+
# fail
|
70
|
+
def validate! config
|
51
71
|
# http configuration
|
52
72
|
# port
|
53
73
|
begin
|
54
|
-
server = TCPServer.new
|
55
|
-
rescue
|
56
|
-
STDERR.puts "
|
74
|
+
server = TCPServer.new config[:port]
|
75
|
+
rescue
|
76
|
+
STDERR.puts "#{config[:address]}:#{config[:port]}: " + $!
|
57
77
|
#TODO: we should give an option of ephemeral port support
|
58
|
-
exit(1)
|
78
|
+
exit(1)
|
59
79
|
end
|
60
80
|
server.close
|
61
81
|
|
@@ -63,25 +83,25 @@ module GlassFish
|
|
63
83
|
if(config[:daemon])
|
64
84
|
os = java.lang.System.getProperty("os.name").downcase
|
65
85
|
version = java.lang.System.getProperty("os.version")
|
66
|
-
#check the platform, Currently daemon mode works only on linux and
|
86
|
+
#check the platform, Currently daemon mode works only on linux and
|
67
87
|
#solaris
|
68
88
|
if(!os.include?("linux") and !os.include?("sunos"))
|
69
89
|
Config.fail "You are running on #{java.lang.System.getProperty("os.name")} #{version}. Currently daemon mode only works on Linux or Solaris platforms!"
|
70
90
|
end
|
71
|
-
|
91
|
+
|
72
92
|
# In daemon mode you can't log to console. Let's fail and let user spcifiy the log file explicitly
|
73
93
|
if(config[:log_console])
|
74
94
|
Config.fail "Daemon mode detected, console logging is disabled in daemon mode. You must provide path to log file with --log|-l option in daemon mode."
|
75
95
|
end
|
76
|
-
|
77
|
-
|
96
|
+
|
97
|
+
|
78
98
|
if(config[:jvm_options].nil?)
|
79
99
|
config[:jvm_options] = DEFAULT_JVM_OPTS
|
80
100
|
end
|
81
101
|
if(config[:pid].nil?)
|
82
102
|
config[:pid] = PID_FILE
|
83
103
|
end
|
84
|
-
|
104
|
+
|
85
105
|
Config.absolutize config[:app_dir], config[:pid]
|
86
106
|
end
|
87
107
|
|
@@ -91,6 +111,11 @@ module GlassFish
|
|
91
111
|
Config.fail "\t0 OFF\n\t1 SEVERE \n\t2 WARNING\n\t3 INFO(default)\n\t4 FINE\n\t5 FINER\n\t6 FINEST\n\t7 ALL\n"
|
92
112
|
end
|
93
113
|
|
114
|
+
if config[:runtimes] > config[:runtimes_max]
|
115
|
+
puts "Initial number of runtimes #{config[:runtimes]} is > max runtime #{config[:runtimes_max]}.\nIncreasing runtimes-max to #{config[:runtimes]}"
|
116
|
+
config[:runtimes_max] = config[:runtimes]
|
117
|
+
end
|
118
|
+
|
94
119
|
# JRuby runtime
|
95
120
|
runtimes_err = " Invalid runtime configuration, initial:#{config[:runtimes]}, min:#{config[:runtimes_min]}, max:#{config[:runtimes_max]}."
|
96
121
|
err = false
|
@@ -133,7 +158,7 @@ module GlassFish
|
|
133
158
|
end
|
134
159
|
|
135
160
|
|
136
|
-
# pid file
|
161
|
+
# pid file
|
137
162
|
#
|
138
163
|
if(!config[:pid].nil? and !config[:daemon])
|
139
164
|
GlassFish::Config::fail("--pid option can only be used with --daemon.")
|
@@ -145,12 +170,11 @@ module GlassFish
|
|
145
170
|
domaindir = File.join(config[:app_dir], "tmp", ".glassfish")
|
146
171
|
config[:domain_dir] = File.expand_path(domaindir)
|
147
172
|
|
148
|
-
if !
|
149
|
-
puts "ERROR: Failed to create GlassFish domain directory: #{domaindir}"
|
173
|
+
if !check_domain_dir?domaindir
|
150
174
|
exit -1
|
151
175
|
end
|
152
176
|
end
|
153
|
-
|
177
|
+
|
154
178
|
def self.fail(message)
|
155
179
|
STDERR.puts "ERROR: #{message}"
|
156
180
|
STDERR.puts "Type 'glassfish -h' to get help"
|
@@ -167,64 +191,34 @@ module GlassFish
|
|
167
191
|
end
|
168
192
|
path
|
169
193
|
end
|
170
|
-
|
194
|
+
|
171
195
|
|
172
196
|
private
|
173
197
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
def setup_temp_domain? config_dir
|
180
|
-
if !File.exist? config_dir
|
181
|
-
FileUtils.mkdir_p config_dir
|
198
|
+
def check_domain_dir?(domain_dir)
|
199
|
+
#create Glassfish domain directory if it does not exist
|
200
|
+
unless File.exist? domain_dir
|
201
|
+
File.makedirs(domain_dir)
|
202
|
+
return true
|
182
203
|
end
|
183
204
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
189
|
-
|
190
|
-
def check_domain_dir?(config_dir)
|
191
|
-
if !File.writable_real?config_dir
|
192
|
-
return false
|
205
|
+
config_dir = File.join(domain_dir, "config")
|
206
|
+
unless File.exist? config_dir
|
207
|
+
File.makedirs(config_dir)
|
208
|
+
return true
|
193
209
|
end
|
194
|
-
src = File.dirname(__FILE__)+File::SEPARATOR+".."+File::SEPARATOR+"domains"+File::SEPARATOR+"domain1"+File::SEPARATOR+"config"
|
195
|
-
File.cp(File.join(src,"domain.xml"), config_dir)
|
196
|
-
File.cp(File.join(src,"logging.properties"), config_dir)
|
197
|
-
|
198
|
-
#make sure both these files are writable
|
199
|
-
FileUtils.chmod(0755, File.join(config_dir,"domain.xml"))
|
200
|
-
FileUtils.chmod(0755, File.join(config_dir,"logging.properties"))
|
201
210
|
|
202
|
-
|
203
|
-
|
204
|
-
#
|
205
|
-
#Returns true if there is glasfish_gem_version.yml file and has the same
|
206
|
-
#version as the glassfish gem. Otherwise creates a new file and returns
|
207
|
-
#false so that rest of the stuff can be created
|
208
|
-
#
|
209
|
-
def same_version?(config_dir)
|
210
|
-
f = File.join(config_dir, 'glassfish_gem_version.yml')
|
211
|
-
if !File.exist? f
|
212
|
-
src = File.join(File.dirname(__FILE__), "..", "domains", "domain1", "config", "glassfish_gem_version.yml")
|
213
|
-
File.cp src, config_dir
|
211
|
+
if !File.writable_real?config_dir
|
212
|
+
puts "ERROR: GlassFish temporary directory: #{config_dir} not writable. Please give write permission to proceed."
|
214
213
|
return false
|
215
214
|
end
|
216
|
-
file = File.open(f)
|
217
|
-
data = YAML::load(file)
|
218
215
|
|
219
|
-
#
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
version = data['glassfish'].fetch('version', nil)
|
224
|
-
if(version.nil?)
|
225
|
-
return false
|
216
|
+
#glassfish gem <=0.9.5 created domain.xml, this causes latter version
|
217
|
+
#to fail so removing this as no more needed
|
218
|
+
if(File.exist?(config_dir) and File.exist?(File.join(config_dir, "domain.xml")))
|
219
|
+
FileUtils.rmtree config_dir
|
226
220
|
end
|
227
|
-
|
221
|
+
true
|
228
222
|
end
|
229
223
|
end
|
230
224
|
end
|