jettywrapper 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 813ec58e9127d32a6aaed77b56e1c2cb31d1bdbb
4
- data.tar.gz: 753964035ecaa0ed84892a19b1aab2b46b2895f8
3
+ metadata.gz: f7d661a0b7e7c0b5237898916aa1a4c7a325f2ce
4
+ data.tar.gz: a2e348d77b9c9a9532fa7aa9d6633c37dfc7ec7d
5
5
  SHA512:
6
- metadata.gz: aa1910b5f5bc64b14dafde8a86ab1e0350b6058b6c23f5a584c55ff284409d48533c148cf6bf218408a7d6c1587b4194e4895bb56da948ce496ab09427fbe67b
7
- data.tar.gz: 38a177af1bf449317caa58cf8af91b2b5818a4b9cb7d48df7cb80ab79710dc37afe56042dcf97b89a0af7918ff56785fd9c6717b560f517af06b8dbbf2cb5d50
6
+ metadata.gz: 4a63cd1bd6ef04567f343e5e222a4764b5b0be3c735e70de32b61acf1084d4330b86ff8633863fb31445a9ae2399ca16a4fd2ac6de3b63809f496d83672aff5a
7
+ data.tar.gz: c25b1b9f5ff6290b76708bdc7857c3d15440b9db29091872a51dd11eb6ac141309af8caff1c368932d9158dd2426e399c55c3b7e25eb98c1d5a3f25ea2a95834
@@ -1,3 +1,6 @@
1
+ 1.8.0
2
+ 2014-07-16: Removed mediashelf-loggable dependency [Justin Coyne]
3
+
1
4
  1.4.0
2
5
  Download jetty from a zip file
3
6
 
@@ -20,14 +20,13 @@ Gem::Specification.new do |s|
20
20
  s.required_rubygems_version = ">= 1.3.6"
21
21
 
22
22
  s.add_dependency "logger"
23
- s.add_dependency "mediashelf-loggable"
24
23
  s.add_dependency "childprocess"
25
24
  s.add_dependency "i18n"
26
25
  s.add_dependency "activesupport", ">=3.0.0"
27
26
 
28
- s.add_development_dependency "rspec"
27
+ s.add_development_dependency "rspec", '~> 2.99'
28
+ s.add_development_dependency "rspec-its"
29
29
  s.add_development_dependency 'rake'
30
-
31
30
 
32
31
  s.add_development_dependency 'yard'#, '0.6.5' # Yard > 0.6.5 won't generate docs.
33
32
  # I don't know why & don't have time to
@@ -1,4 +1,3 @@
1
- require 'loggable'
2
1
  require 'singleton'
3
2
  require 'fileutils'
4
3
  require 'shellwords'
@@ -16,7 +15,6 @@ Dir[File.expand_path(File.join(File.dirname(__FILE__),"tasks/*.rake"))].each { |
16
15
  class Jettywrapper
17
16
 
18
17
  include Singleton
19
- include Loggable
20
18
  include ActiveSupport::Benchmarkable
21
19
 
22
20
 
@@ -304,155 +302,167 @@ class Jettywrapper
304
302
  return false
305
303
  end
306
304
  end
305
+
306
+ def logger=(logger)
307
+ @@logger = logger
308
+ end
309
+
310
+ # If ::Rails.logger is defined, that will be returned.
311
+ # If no logger has been defined, a new STDOUT Logger will be created.
312
+ def logger
313
+ @@logger ||= defined?(::Rails) ? ::Rails.logger : ::Logger.new(STDOUT)
314
+ end
315
+
316
+ end #end of class << self
307
317
 
308
- end #end of class << self
309
-
318
+ def logger
319
+ self.class.logger
320
+ end
310
321
 
311
- # What command is being run to invoke jetty?
312
- def jetty_command
313
- ["java", java_variables, java_opts, "-jar", "start.jar", jetty_opts].flatten
314
- end
315
-
316
- def java_variables
317
- ["-Djetty.port=#{@port}",
318
- "-Dsolr.solr.home=#{Shellwords.escape(@solr_home)}"]
319
- end
320
-
321
- # Start the jetty server. Check the pid file to see if it is running already,
322
- # and stop it if so. After you start jetty, write the PID to a file.
323
- # This is the instance start method. It must be called on Jettywrapper.instance
324
- # You're probably better off using Jettywrapper.start(:jetty_home => "/path/to/jetty")
325
- # @example
326
- # Jettywrapper.configure(params)
327
- # Jettywrapper.instance.start
328
- # return Jettywrapper.instance
329
- def start
330
- logger.debug "Starting jetty with these values: "
331
- logger.debug "jetty_home: #{@jetty_home}"
332
- logger.debug "jetty_command: #{jetty_command.join(' ')}"
333
-
334
- # Check to see if we can start.
335
- # 1. If there is a pid, check to see if it is really running
336
- # 2. Check to see if anything is blocking the port we want to use
337
- if pid
338
- if Jettywrapper.is_pid_running?(pid)
339
- raise("Server is already running with PID #{pid}")
340
- else
341
- logger.warn "Removing stale PID file at #{pid_path}"
342
- File.delete(pid_path)
343
- end
344
- end
345
- if Jettywrapper.is_port_in_use?(self.port)
346
- raise("Port #{self.port} is already in use.")
347
- end
348
- benchmark "Started jetty" do
349
- Dir.chdir(@jetty_home) do
350
- process.start
351
- end
352
- FileUtils.makedirs(pid_dir) unless File.directory?(pid_dir)
353
- begin
354
- f = File.new(pid_path, "w")
355
- rescue Errno::ENOENT, Errno::EACCES
356
- f = File.new(File.join(base_path,'tmp',pid_file),"w")
357
- end
358
- f.puts "#{process.pid}"
359
- f.close
360
- logger.debug "Wrote pid file to #{pid_path} with value #{process.pid}"
361
- startup_wait!
362
- end
363
- end
364
-
365
- # Wait for the jetty server to start and begin listening for requests
366
- def startup_wait!
367
- begin
368
- Timeout::timeout(startup_wait) do
369
- sleep 1 until (Jettywrapper.is_port_in_use? self.port)
370
- end
371
- rescue Timeout::Error
372
- logger.warn "Waited #{startup_wait} seconds for jetty to start, but it is not yet listening on port #{self.port}. Continuing anyway."
373
- end
374
- end
375
-
376
- def process
377
- @process ||= begin
378
- process = ChildProcess.build(*jetty_command)
379
- if self.quiet
380
- process.io.stderr = File.open(File.expand_path("jettywrapper.log"), "w+")
381
- process.io.stdout = process.io.stderr
382
- logger.warn "Logging jettywrapper stdout to #{File.expand_path(process.io.stderr.path)}"
383
- else
384
- process.io.inherit!
385
- end
386
- process.detach = true
322
+ # What command is being run to invoke jetty?
323
+ def jetty_command
324
+ ["java", java_variables, java_opts, "-jar", "start.jar", jetty_opts].flatten
325
+ end
326
+
327
+ def java_variables
328
+ ["-Djetty.port=#{@port}",
329
+ "-Dsolr.solr.home=#{Shellwords.escape(@solr_home)}"]
330
+ end
387
331
 
388
- process
332
+ # Start the jetty server. Check the pid file to see if it is running already,
333
+ # and stop it if so. After you start jetty, write the PID to a file.
334
+ # This is the instance start method. It must be called on Jettywrapper.instance
335
+ # You're probably better off using Jettywrapper.start(:jetty_home => "/path/to/jetty")
336
+ # @example
337
+ # Jettywrapper.configure(params)
338
+ # Jettywrapper.instance.start
339
+ # return Jettywrapper.instance
340
+ def start
341
+ logger.debug "Starting jetty with these values: "
342
+ logger.debug "jetty_home: #{@jetty_home}"
343
+ logger.debug "jetty_command: #{jetty_command.join(' ')}"
344
+
345
+ # Check to see if we can start.
346
+ # 1. If there is a pid, check to see if it is really running
347
+ # 2. Check to see if anything is blocking the port we want to use
348
+ if pid
349
+ if Jettywrapper.is_pid_running?(pid)
350
+ raise("Server is already running with PID #{pid}")
351
+ else
352
+ logger.warn "Removing stale PID file at #{pid_path}"
353
+ File.delete(pid_path)
354
+ end
355
+ end
356
+ if Jettywrapper.is_port_in_use?(self.port)
357
+ raise("Port #{self.port} is already in use.")
358
+ end
359
+ benchmark "Started jetty" do
360
+ Dir.chdir(@jetty_home) do
361
+ process.start
362
+ end
363
+ FileUtils.makedirs(pid_dir) unless File.directory?(pid_dir)
364
+ begin
365
+ f = File.new(pid_path, "w")
366
+ rescue Errno::ENOENT, Errno::EACCES
367
+ f = File.new(File.join(base_path,'tmp',pid_file),"w")
389
368
  end
390
- end
391
-
392
- def reset_process!
393
- @process = nil
394
- end
395
- # Instance stop method. Must be called on Jettywrapper.instance
396
- # You're probably better off using Jettywrapper.stop(:jetty_home => "/path/to/jetty")
397
- # @example
398
- # Jettywrapper.configure(params)
399
- # Jettywrapper.instance.stop
400
- # return Jettywrapper.instance
401
- def stop
402
- logger.debug "Instance stop method called for pid '#{pid}'"
403
- if pid
404
- if @process
405
- @process.stop
369
+ f.puts "#{process.pid}"
370
+ f.close
371
+ logger.debug "Wrote pid file to #{pid_path} with value #{process.pid}"
372
+ startup_wait!
373
+ end
374
+ end
375
+
376
+ # Wait for the jetty server to start and begin listening for requests
377
+ def startup_wait!
378
+ begin
379
+ Timeout::timeout(startup_wait) do
380
+ sleep 1 until (Jettywrapper.is_port_in_use? self.port)
381
+ end
382
+ rescue Timeout::Error
383
+ logger.warn "Waited #{startup_wait} seconds for jetty to start, but it is not yet listening on port #{self.port}. Continuing anyway."
384
+ end
385
+ end
386
+
387
+ def process
388
+ @process ||= begin
389
+ process = ChildProcess.build(*jetty_command)
390
+ if self.quiet
391
+ process.io.stderr = File.open(File.expand_path("jettywrapper.log"), "w+")
392
+ process.io.stdout = process.io.stderr
393
+ logger.warn "Logging jettywrapper stdout to #{File.expand_path(process.io.stderr.path)}"
406
394
  else
407
- Process.kill("KILL", pid) rescue nil
395
+ process.io.inherit!
408
396
  end
397
+ process.detach = true
409
398
 
410
- begin
411
- File.delete(pid_path)
412
- rescue
413
- end
399
+ process
414
400
  end
415
- end
416
-
401
+ end
417
402
 
418
- # The fully qualified path to the pid_file
419
- def pid_path
420
- #need to memoize this, becasuse the base path could be relative and the cwd can change in the yield block of wrap
421
- @path ||= File.join(pid_dir, pid_file)
422
- end
403
+ def reset_process!
404
+ @process = nil
405
+ end
406
+
407
+ # Instance stop method. Must be called on Jettywrapper.instance
408
+ # You're probably better off using Jettywrapper.stop(:jetty_home => "/path/to/jetty")
409
+ # @example
410
+ # Jettywrapper.configure(params)
411
+ # Jettywrapper.instance.stop
412
+ # return Jettywrapper.instance
413
+ def stop
414
+ logger.debug "Instance stop method called for pid '#{pid}'"
415
+ if pid
416
+ if @process
417
+ @process.stop
418
+ else
419
+ Process.kill("KILL", pid) rescue nil
420
+ end
423
421
 
424
- # The file where the process ID will be written
425
- def pid_file
426
- jetty_home_to_pid_file(@jetty_home)
427
- end
428
-
429
- # Take the @jetty_home value and transform it into a legal filename
430
- # @return [String] the name of the pid_file
431
- # @example
432
- # /usr/local/jetty1 => _usr_local_jetty1.pid
433
- def jetty_home_to_pid_file(jetty_home)
434
422
  begin
435
- jetty_home.gsub(/\//,'_') << "_#{self.class.env}" << ".pid"
436
- rescue Exception => e
437
- raise "Couldn't make a pid file for jetty_home value #{jetty_home}\n Caused by: #{e}"
423
+ File.delete(pid_path)
424
+ rescue
438
425
  end
439
426
  end
427
+ end
428
+
440
429
 
441
- # The directory where the pid_file will be written
442
- def pid_dir
443
- File.expand_path(File.join(base_path,'tmp','pids'))
444
- end
430
+ # The fully qualified path to the pid_file
431
+ def pid_path
432
+ #need to memoize this, becasuse the base path could be relative and the cwd can change in the yield block of wrap
433
+ @path ||= File.join(pid_dir, pid_file)
434
+ end
435
+
436
+ # The file where the process ID will be written
437
+ def pid_file
438
+ jetty_home_to_pid_file(@jetty_home)
439
+ end
445
440
 
446
- # Check to see if there is a pid file already
447
- # @return true if the file exists, otherwise false
448
- def pid_file?
449
- return true if File.exist?(pid_path)
450
- false
451
- end
452
-
453
- # the process id of the currently running jetty instance
454
- def pid
455
- File.open( pid_path ) { |f| return f.gets.to_i } if File.exist?(pid_path)
456
- end
441
+ # Take the @jetty_home value and transform it into a legal filename
442
+ # @return [String] the name of the pid_file
443
+ # @example
444
+ # /usr/local/jetty1 => _usr_local_jetty1.pid
445
+ def jetty_home_to_pid_file(jetty_home)
446
+ begin
447
+ jetty_home.gsub(/\//,'_') << "_#{self.class.env}" << ".pid"
448
+ rescue Exception => e
449
+ raise "Couldn't make a pid file for jetty_home value #{jetty_home}\n Caused by: #{e}"
450
+ end
451
+ end
452
+
453
+ # The directory where the pid_file will be written
454
+ def pid_dir
455
+ File.expand_path(File.join(base_path,'tmp','pids'))
456
+ end
457
457
 
458
+ # Check to see if there is a pid file already
459
+ # @return true if the file exists, otherwise false
460
+ def pid_file?
461
+ File.exist?(pid_path)
462
+ end
463
+
464
+ # the process id of the currently running jetty instance
465
+ def pid
466
+ File.open( pid_path ) { |f| return f.gets.to_i } if File.exist?(pid_path)
467
+ end
458
468
  end
@@ -1,3 +1,3 @@
1
1
  class Jettywrapper
2
- VERSION = "1.7.0"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -8,7 +8,7 @@ if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
8
8
  SimpleCov.start
9
9
  end
10
10
 
11
- require 'rspec/autorun'
11
+ require 'rspec/its'
12
12
  require 'jettywrapper'
13
13
 
14
14
  RSpec.configure do |config|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jettywrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-10 00:00:00.000000000 Z
13
+ date: 2014-07-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: logger
@@ -27,7 +27,7 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
30
- name: mediashelf-loggable
30
+ name: childprocess
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="
@@ -41,7 +41,7 @@ dependencies:
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
- name: childprocess
44
+ name: i18n
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
@@ -55,35 +55,35 @@ dependencies:
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
- name: i18n
58
+ name: activesupport
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: '0'
63
+ version: 3.0.0
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: 3.0.0
71
71
  - !ruby/object:Gem::Dependency
72
- name: activesupport
72
+ name: rspec
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 3.0.0
78
- type: :runtime
77
+ version: '2.99'
78
+ type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ">="
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 3.0.0
84
+ version: '2.99'
85
85
  - !ruby/object:Gem::Dependency
86
- name: rspec
86
+ name: rspec-its
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="