torquebox-rake-support 2.0.0 → 2.0.1

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.
@@ -183,7 +183,7 @@ module TorqueBox
183
183
  end
184
184
 
185
185
  cmd = "jar cvf #{archive_path} #{include_files.join(' ')}"
186
- exec_command( cmd )
186
+ run_command( cmd )
187
187
  end
188
188
 
189
189
  archive_path
@@ -193,8 +193,8 @@ module TorqueBox
193
193
  Dir.chdir( app_dir ) do
194
194
  jruby = File.join( RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] )
195
195
  jruby << " --1.9" if RUBY_VERSION =~ /^1\.9\./
196
- exec_command( "#{jruby} -S bundle package" )
197
- exec_command( "#{jruby} -S bundle install --local --path vendor/bundle" )
196
+ run_command( "#{jruby} -S bundle package" )
197
+ run_command( "#{jruby} -S bundle install --local --path vendor/bundle" )
198
198
  end
199
199
  end
200
200
 
@@ -288,29 +288,61 @@ module TorqueBox
288
288
  success
289
289
  end
290
290
 
291
+ # Used when we want to effectively replace this process with the
292
+ # given command. On Windows this does call Kernel#exec but on
293
+ # everything else we just delegate to run_command.
294
+ #
295
+ # This is mainly so CTRL+C, STDIN, STDOUT, and STDERR work as
296
+ # expected across all operating systems.
291
297
  def exec_command(cmd)
292
- IO.popen4( cmd ) do |pid, stdin, stdout, stderr|
298
+ windows? ? exec(cmd) : run_command(cmd)
299
+ end
300
+
301
+ # Used to run a command as a subprocess
302
+ def run_command(cmd)
303
+ exiting = false
304
+ IO.popen4(cmd) do |pid, stdin, stdout, stderr|
305
+ stdout.sync = true
306
+ stderr.sync = true
293
307
  trap("INT") do
308
+ exiting = true
309
+ stdin.close
294
310
  puts "caught SIGINT, shutting down"
295
311
  `taskkill /F /T /PID #{pid}` if windows?
296
312
  end
297
- stdin.close
298
- [
299
- Thread.new(stdout) {|stdout_io|
300
- stdout_io.each_line do |l|
301
- STDOUT.puts l
302
- STDOUT.flush
303
- end
304
- stdout_io.close
305
- },
306
-
307
- Thread.new(stderr) {|stderr_io|
308
- stderr_io.each_line do |l|
309
- STDERR.puts l
310
- STDERR.flush
311
- end
312
- }
313
- ].each( &:join )
313
+
314
+ # Don't join on stdin since interrupting a blocking read on
315
+ # JRuby is pretty tricky
316
+ Thread.new(stdin) { |stdin_io|
317
+ begin
318
+ until exiting
319
+ stdin_io.write(STDIN.readpartial(1024))
320
+ stdin_io.flush
321
+ end
322
+ rescue Errno::EBADF, IOError
323
+ end
324
+ }
325
+
326
+ # Join on stdout/stderr since they'll be closed
327
+ # automatically once TorqueBox exits
328
+ [ Thread.new(stdout) { |stdout_io|
329
+ begin
330
+ while true
331
+ STDOUT.write(stdout_io.readpartial(1024))
332
+ end
333
+ rescue EOFError
334
+ end
335
+ },
336
+
337
+ Thread.new(stderr) { |stderr_io|
338
+ begin
339
+ while true
340
+ STDERR.write(stderr_io.readpartial(1024))
341
+ end
342
+ rescue EOFError
343
+ end
344
+ }
345
+ ].each( &:join)
314
346
  end
315
347
 
316
348
  end
@@ -74,7 +74,7 @@ module TorqueBox
74
74
  end
75
75
  end
76
76
  puts "Created launchd plist #{plist_file}, loading now."
77
- TorqueBox::DeployUtils.exec_command "launchctl load #{plist_file}"
77
+ TorqueBox::DeployUtils.run_command "launchctl load #{plist_file}"
78
78
  check_install
79
79
  FileUtils.mkdir_p log_dir, :mode => 0755 unless File.exists? log_dir
80
80
  end
@@ -48,18 +48,18 @@ namespace :torquebox do
48
48
 
49
49
  desc "Start TorqueBox when running as a launchd daemon"
50
50
  task :start=>[ :check ] do
51
- TorqueBox::DeployUtils.exec_command( 'launchctl start org.torquebox.TorqueBox' )
51
+ TorqueBox::DeployUtils.run_command( 'launchctl start org.torquebox.TorqueBox' )
52
52
  end
53
53
 
54
54
  desc "Stop TorqueBox when running as an launchd daemon"
55
55
  task :stop=>[ :check ] do
56
- TorqueBox::DeployUtils.exec_command( 'launchctl stop org.torquebox.TorqueBox' )
56
+ TorqueBox::DeployUtils.run_command( 'launchctl stop org.torquebox.TorqueBox' )
57
57
  end
58
58
 
59
59
  desc "Restart TorqueBox when running as an launchd daemon"
60
60
  task :restart=>[ :check ] do
61
- TorqueBox::DeployUtils.exec_command( 'launchctl stop org.torquebox.TorqueBox' )
62
- TorqueBox::DeployUtils.exec_command( 'launchctl start org.torquebox.TorqueBox' )
61
+ TorqueBox::DeployUtils.run_command( 'launchctl stop org.torquebox.TorqueBox' )
62
+ TorqueBox::DeployUtils.run_command( 'launchctl start org.torquebox.TorqueBox' )
63
63
  end
64
64
 
65
65
  end
@@ -80,17 +80,17 @@ namespace :torquebox do
80
80
 
81
81
  desc "Start TorqueBox when running as an upstart service"
82
82
  task :start=>[ :check ] do
83
- TorqueBox::DeployUtils.exec_command( 'start torquebox' )
83
+ TorqueBox::DeployUtils.run_command( 'start torquebox' )
84
84
  end
85
85
 
86
86
  desc "Stop TorqueBox when running as an upstart service"
87
87
  task :stop=>[ :check ] do
88
- TorqueBox::DeployUtils.exec_command( 'stop torquebox' )
88
+ TorqueBox::DeployUtils.run_command( 'stop torquebox' )
89
89
  end
90
90
 
91
91
  desc "Restart TorqueBox when running as an upstart service"
92
92
  task :restart=>[ :check ] do
93
- TorqueBox::DeployUtils.exec_command( 'restart torquebox' )
93
+ TorqueBox::DeployUtils.run_command( 'restart torquebox' )
94
94
  end
95
95
 
96
96
  end
@@ -350,7 +350,7 @@ describe TorqueBox::DeployUtils do
350
350
 
351
351
  describe '.create_archive' do
352
352
  it 'should not include excluded dirs and files' do
353
- @util.should_receive(:exec_command) do |arg|
353
+ @util.should_receive(:run_command) do |arg|
354
354
  ["config.ru", "app"].permutation.map {|p|
355
355
  "jar cvf /tmp/simpleapp.knob #{p.join(" ")}"
356
356
  }.should include(arg)
@@ -366,7 +366,7 @@ describe TorqueBox::DeployUtils do
366
366
  end
367
367
 
368
368
  it 'should exclude based on patterns' do
369
- @util.should_receive(:exec_command) do |arg|
369
+ @util.should_receive(:run_command) do |arg|
370
370
  ["puppet", "config.ru", "app"].permutation.map {|p|
371
371
  "jar cvf /tmp/simpleapp.knob #{p.join(" ")}"
372
372
  }.should include(arg)
@@ -382,7 +382,7 @@ describe TorqueBox::DeployUtils do
382
382
  end
383
383
 
384
384
  it 'should include all dirs and files except default' do
385
- @util.should_receive(:exec_command) do |arg|
385
+ @util.should_receive(:run_command) do |arg|
386
386
  ["config.ru", "app", "puppet", "simpleapp.box"].permutation.map {|p|
387
387
  "jar cvf /tmp/simpleapp.knob #{p.join(" ")}"
388
388
  }.should include(arg)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: torquebox-rake-support
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.0
5
+ version: 2.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - The TorqueBox Team
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-03-31 00:00:00 Z
13
+ date: 2012-04-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -50,25 +50,25 @@ files:
50
50
  - licenses/lgpl-2.1.txt
51
51
  - lib/org.torquebox.rake-support.rb
52
52
  - lib/torquebox-rake-support.rb
53
- - lib/torquebox/rails.rb
54
53
  - lib/torquebox/deploy_utils.rb
55
- - lib/torquebox/launchd.rb
56
- - lib/torquebox/server.rb
54
+ - lib/torquebox/rails.rb
57
55
  - lib/torquebox/upstart.rb
56
+ - lib/torquebox/server.rb
57
+ - lib/torquebox/launchd.rb
58
58
  - lib/torquebox/rake/tasks.rb
59
+ - lib/torquebox/rake/tasks/archive.rb
59
60
  - lib/torquebox/rake/tasks/server.rb
60
61
  - lib/torquebox/rake/tasks/deployment.rb
61
- - lib/torquebox/rake/tasks/archive.rb
62
- - generators/torquebox_queue_generator.rb
63
62
  - generators/USAGE
63
+ - generators/torquebox_queue_generator.rb
64
64
  - generators/templates/queue.rb
65
+ - spec/spec_helper.rb
65
66
  - spec/rails_spec.rb
67
+ - spec/server_spec.rb
66
68
  - spec/deploy_utils_spec.rb
67
69
  - spec/upstart_spec.rb
68
- - spec/spec_helper.rb
69
- - spec/server_spec.rb
70
- - spec/fixtures/simpleapp/simpleapp.box
71
70
  - spec/fixtures/simpleapp/config.ru
71
+ - spec/fixtures/simpleapp/simpleapp.box
72
72
  homepage: http://torquebox.org/
73
73
  licenses:
74
74
  - lgpl
@@ -98,6 +98,6 @@ specification_version: 3
98
98
  summary: TorqueBox Rake Support
99
99
  test_files:
100
100
  - spec/rails_spec.rb
101
+ - spec/server_spec.rb
101
102
  - spec/deploy_utils_spec.rb
102
103
  - spec/upstart_spec.rb
103
- - spec/server_spec.rb