lib/appengine-tools/dev_appserver.rb in appengine-tools-0.0.2 vs lib/appengine-tools/dev_appserver.rb in appengine-tools-0.0.3
- old
+ new
@@ -15,32 +15,68 @@
# limitations under the License.
require 'appengine-sdk'
require 'appengine-tools/boot'
require 'appengine-tools/bundler'
+require 'appengine-tools/update_check'
module AppEngine
module Development
- DEV_APPSERVER = 'com.google.appengine.tools.development.DevAppServerMain'
+ DEV_APPSERVER = ['com.google.appengine.tools.development.DevAppServerMain']
class JRubyDevAppserver
class << self
def run(args)
- path = args[-1] || '.'
- if args.length > 0 and File::directory?(args[-1])
- unless ENV['BOOTING_DEVAPPSERVER']
- puts "=> Booting DevAppServer"
- puts "=> Press Ctrl-C to shutdown server"
- ENV['BOOTING_DEVAPPSERVER'] = 'true'
- end
+ path, java_args, server_args = parse_argv(ARGV)
+ if path and File::directory?(path)
+ puts "=> Booting DevAppServer"
+ puts "=> Press Ctrl-C to shutdown server"
AppEngine::Admin.bundle_app(path)
+ updater = AppEngine::Admin::UpdateCheck.new(path)
+ updater.nag if updater.can_nag?
end
- AppEngine::Development.boot_jruby
- args.unshift(DEV_APPSERVER)
- jruby_home = get_jruby_home(args[-1])
- if jruby_home
- args.unshift("--jvm_flag=-Djruby.home=#{jruby_home}")
+ start_java(path, java_args, server_args)
+ end
+
+ def parse_argv(argv)
+ java_args = []
+ server_args = ['--disable_update_check']
+ start_on_first_thread = false
+ if RUBY_PLATFORM =~ /darwin/ ||
+ (RUBY_PLATFORM == 'java' &&
+ java.lang.System.getProperty("os.name").downcase == "mac os x")
+ start_on_first_thread = true
end
- AppEngine::SDK.load_kickstart.main(args.to_java(:string))
+ argv.each do |arg|
+ if arg =~ /^--jvm_flag=(.+)/
+ java_args << $1
+ elsif arg =~ /--startOnFirstThread=(true|false)/
+ start_on_first_thread = ($1 == "true")
+ else
+ server_args << arg
+ end
+ end
+ if start_on_first_thread
+ java_args << '-XstartOnFirstThread'
+ end
+ return server_args[-1], java_args, server_args
+ end
+
+ def start_java(path, java_args, server_args)
+ if path
+ jruby_home = get_jruby_home(path)
+ java_args << "-Djruby.home=#{jruby_home}" if jruby_home
+ server_args[-1] = File.expand_path(path)
+ Dir.chdir(path)
+ end
+ ENV.delete 'GEM_HOME'
+ ENV.delete 'GEM_PATH'
+ java_args << '-classpath'
+ java_args << AppEngine::SDK::TOOLS_JAR
+ command = ['java'] + java_args + DEV_APPSERVER + server_args
+ if ENV['VERBOSE']
+ puts "exec #{command.map{|x| x.inspect}.join(' ')}"
+ end
+ exec(*command)
end
def get_jruby_home(path)
return unless path
Dir.chdir("#{path}/WEB-INF/lib") do