torquebox-rake-support 2.0.0.beta2 → 2.0.0.beta3
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.
@@ -153,7 +153,10 @@ module TorqueBox
|
|
153
153
|
archive = normalize_archive_name( find_option( opts, 'name' ) || archive_name )
|
154
154
|
app_dir = find_option( opts, 'app_dir') || Dir.pwd
|
155
155
|
dest_dir = find_option( opts, 'dest_dir') || Dir.pwd
|
156
|
-
|
156
|
+
|
157
|
+
default_skip_files = %w{ ^log$ ^tmp$ ^test$ ^spec$ \.knob$ vendor }
|
158
|
+
opts_skip_files = (find_option(opts, 'exclude') || "").split(/,/)
|
159
|
+
skip_files = default_skip_files + opts_skip_files
|
157
160
|
|
158
161
|
archive_path = File.join(dest_dir, archive)
|
159
162
|
|
data/lib/torquebox/upstart.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
# Helpers for upstart rake tasks
|
19
19
|
|
20
|
+
require 'erb'
|
20
21
|
require 'torquebox/deploy_utils'
|
21
22
|
|
22
23
|
module TorqueBox
|
@@ -35,9 +36,16 @@ module TorqueBox
|
|
35
36
|
File.join( init_dir, 'torquebox.conf' )
|
36
37
|
end
|
37
38
|
|
38
|
-
def copy_init_script
|
39
|
+
def copy_init_script(opts={})
|
39
40
|
if File.writable?( init_dir )
|
40
|
-
|
41
|
+
if ( server_opts = TorqueBox::DeployUtils.find_option(opts, 'server_opts') )
|
42
|
+
to_init_file = File.join( init_dir, File.basename(init_script) )
|
43
|
+
File.open( to_init_file, 'w' ) do |f|
|
44
|
+
f.write( process_init_template(server_opts) )
|
45
|
+
end
|
46
|
+
else
|
47
|
+
FileUtils.cp( init_script, init_dir )
|
48
|
+
end
|
41
49
|
else
|
42
50
|
puts "Cannot write upstart configuration to #{init_dir}. You'll need to copy #{init_script} to #{init_dir} yourself."
|
43
51
|
end
|
@@ -49,6 +57,11 @@ module TorqueBox
|
|
49
57
|
puts "TorqueBox init scripts OK: #{init_torquebox}"
|
50
58
|
end
|
51
59
|
|
60
|
+
# param names are important to the template
|
61
|
+
def process_init_template(server_opts)
|
62
|
+
template = ERB.new File.new( "#{init_script}.erb" ).read
|
63
|
+
template.result(binding)
|
64
|
+
end
|
52
65
|
end
|
53
66
|
end
|
54
67
|
end
|
data/spec/deploy_utils_spec.rb
CHANGED
@@ -306,4 +306,53 @@ describe TorqueBox::DeployUtils do
|
|
306
306
|
options.should include('-b 0.0.0.0')
|
307
307
|
end
|
308
308
|
end
|
309
|
+
|
310
|
+
describe '.create_archive' do
|
311
|
+
it 'should not include excluded dirs and files' do
|
312
|
+
@util.should_receive(:exec_command) do |arg|
|
313
|
+
["config.ru", "app"].permutation.map {|p|
|
314
|
+
"jar cvf /tmp/simpleapp.knob #{p.join(" ")}"
|
315
|
+
}.should include(arg)
|
316
|
+
end
|
317
|
+
|
318
|
+
path = @util.create_archive(
|
319
|
+
:name => "simpleapp",
|
320
|
+
:app_dir => File.join(File.dirname(__FILE__), 'fixtures/simpleapp'),
|
321
|
+
:dest_dir => "/tmp",
|
322
|
+
:exclude => "puppet,simpleapp.box"
|
323
|
+
)
|
324
|
+
path.should == "/tmp/simpleapp.knob"
|
325
|
+
end
|
326
|
+
|
327
|
+
it 'should exclude based on patterns' do
|
328
|
+
@util.should_receive(:exec_command) do |arg|
|
329
|
+
["puppet", "config.ru", "app"].permutation.map {|p|
|
330
|
+
"jar cvf /tmp/simpleapp.knob #{p.join(" ")}"
|
331
|
+
}.should include(arg)
|
332
|
+
end
|
333
|
+
|
334
|
+
path = @util.create_archive(
|
335
|
+
:name => "simpleapp",
|
336
|
+
:app_dir => File.join(File.dirname(__FILE__), 'fixtures/simpleapp'),
|
337
|
+
:dest_dir => "/tmp",
|
338
|
+
:exclude => ".box"
|
339
|
+
)
|
340
|
+
path.should == "/tmp/simpleapp.knob"
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'should include all dirs and files except default' do
|
344
|
+
@util.should_receive(:exec_command) do |arg|
|
345
|
+
["config.ru", "app", "puppet", "simpleapp.box"].permutation.map {|p|
|
346
|
+
"jar cvf /tmp/simpleapp.knob #{p.join(" ")}"
|
347
|
+
}.should include(arg)
|
348
|
+
end
|
349
|
+
|
350
|
+
path = @util.create_archive(
|
351
|
+
:name => "simpleapp",
|
352
|
+
:app_dir => File.join(File.dirname(__FILE__), 'fixtures/simpleapp'),
|
353
|
+
:dest_dir => "/tmp"
|
354
|
+
)
|
355
|
+
path.should == "/tmp/simpleapp.knob"
|
356
|
+
end
|
357
|
+
end
|
309
358
|
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'torquebox/upstart'
|
2
|
+
|
3
|
+
describe TorqueBox::Upstart do
|
4
|
+
|
5
|
+
describe ".copy_init_script" do
|
6
|
+
it "should not use the template" do
|
7
|
+
pending "need fakefs or similar to properly test copy"
|
8
|
+
# need fakefs or something
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".process_init_template" do
|
13
|
+
it "should substitute the values" do
|
14
|
+
ENV["TORQUEBOX_HOME"] = File.expand_path("..", File.dirname(__FILE__))
|
15
|
+
r = TorqueBox::Upstart.process_init_template("--server-config=standalone-ha.xml")
|
16
|
+
r.should include("--server-config=standalone-ha.xml")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: torquebox-rake-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 2.0.0.
|
5
|
+
version: 2.0.0.beta3
|
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-01-
|
13
|
+
date: 2012-01-24 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -65,6 +65,9 @@ files:
|
|
65
65
|
- spec/deploy_utils_spec.rb
|
66
66
|
- spec/server_spec.rb
|
67
67
|
- spec/spec_helper.rb
|
68
|
+
- spec/upstart_spec.rb
|
69
|
+
- spec/fixtures/simpleapp/config.ru
|
70
|
+
- spec/fixtures/simpleapp/simpleapp.box
|
68
71
|
homepage: http://www.torquebox.org/torquebox-gems-parent/torquebox-rake-support/
|
69
72
|
licenses:
|
70
73
|
- lgpl
|
@@ -95,3 +98,4 @@ summary: TorqueBox Rake Support
|
|
95
98
|
test_files:
|
96
99
|
- spec/deploy_utils_spec.rb
|
97
100
|
- spec/server_spec.rb
|
101
|
+
- spec/upstart_spec.rb
|