torquebox-capistrano-support 1.1.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,115 +17,12 @@
17
17
 
18
18
  require 'capistrano'
19
19
 
20
- Capistrano::Configuration.instance.load do
21
-
22
- # --
23
-
24
- _cset( :app_ruby_version, 1.8 )
25
-
26
- _cset( :torquebox_home, '/opt/torquebox' )
27
- _cset( :jboss_home, lambda{ "#{torquebox_home}/jboss" } )
28
- _cset( :jruby_home, lambda{ "#{torquebox_home}/jruby" } )
29
- _cset( :jruby_opts, lambda{ "--#{app_ruby_version}" } )
30
- _cset( :jruby_bin, lambda{ "#{jruby_home}/bin/jruby #{jruby_opts}" } )
31
-
32
- _cset( :jboss_config, 'default' )
33
-
34
- _cset( :jboss_control_style, :initid )
35
- _cset( :jboss_init_script, '/etc/init.d/jbossas' )
36
-
37
- _cset( :jboss_bind_address, '0.0.0.0' )
38
-
39
- _cset( :bundle_cmd, lambda{ "#{jruby_bin} -S bundle" } )
40
- _cset( :bundle_flags, '' )
41
-
42
-
43
- namespace :deploy do
44
-
45
- desc "Perform a deployment"
46
-
47
- task :default do
48
- update
49
- end
50
-
51
- desc "Start TorqueBox Server"
52
- task :start do
53
- puts "Starting TorqueBox AS"
54
- case ( jboss_control_style )
55
- when :initd
56
- run "#{jboss_init_script} start"
57
- when :binscripts
58
- run "nohup #{jboss_home}/bin/run.sh -b #{jboss_bind_address} -c #{jboss_config} < /dev/null > /dev/null 2>&1 &"
59
- end
60
- end
61
-
62
- desc "Stop TorqueBox Server"
63
- task :stop do
64
- puts "Stopping TorqueBox AS"
65
- case ( jboss_control_style )
66
- when :initd
67
- run "JBOSS_HOME=#{jboss_home} #{jboss_init_script} stop"
68
- when :binscripts
69
- run "#{jboss_home}/bin/shutdown.sh -S"
70
- end
71
- end
72
-
73
- desc "Restart TorqueBox Server"
74
- task :restart do
75
- case ( jboss_control_style )
76
- when :initd
77
- puts "Restarting TorqueBox AS"
78
- puts "JBOSS_HOME=#{jboss_home} #{jboss_init_script} restart"
79
- when :binscripts
80
- puts "deploy:restart only supported with initd control style."
81
- puts "Please use deploy:stop and deploy:start."
82
- end
83
- end
84
-
85
- namespace :torquebox do
86
-
87
- task :info do
88
- puts "torquebox_home.....#{torquebox_home}"
89
- puts "jboss_home.........#{jboss_home}"
90
- puts "jruby_home.........#{jruby_home}"
91
- puts "bundle command.....#{bundle_cmd}"
92
- end
93
-
94
- task :check do
95
- run "test -x #{jboss_init_script}", :roles=>[ :app ]
96
- run "test -d #{jboss_home}", :roles=>[ :app ]
97
- run "test -d #{jboss_home}/server/#{jboss_config}", :roles=>[ :app ]
98
- run "test -w #{jboss_home}/server/#{jboss_config}/deploy", :roles=>[ :app ]
99
- run "test -w #{torquebox_home}/apps", :roles=>[ :app ]
100
- unless ( [ :initd, :binscripts ].include?( jboss_control_style.to_sym ) )
101
- fail "invalid jboss_control_style: #{jboss_control_style}"
102
- end
103
- end
104
-
105
- task :deployment_descriptor do
106
- puts "creating deployment descriptor"
107
- dd_str = YAML.dump_stream( create_deployment_descriptor() )
108
- dd_file = "#{torquebox_home}/apps/#{application}-knob.yml"
109
- dd_tmp_file = "#{dd_file}.tmp"
110
- cmd = "cat /dev/null > #{dd_tmp_file}"
111
- dd_str.each_line do |line|
112
- cmd += " && echo \"#{line}\" >> #{dd_tmp_file}"
113
- end
114
- cmd += " && mv #{dd_tmp_file} #{dd_file}"
115
- run cmd
116
- end
117
- end
118
-
119
-
120
- desc "Dump the deployment descriptor"
121
- task :dump do
122
- puts YAML.dump( create_deployment_descriptor )
123
- end
124
-
125
- def create_deployment_descriptor
20
+ module Capistrano
21
+ class Configuration
22
+ def create_deployment_descriptor( root )
126
23
  dd = {
127
24
  'application'=>{
128
- 'root'=>"#{latest_release}",
25
+ 'root'=>"#{root}",
129
26
  },
130
27
  }
131
28
 
@@ -148,13 +45,132 @@ Capistrano::Configuration.instance.load do
148
45
  dd['environment'] = app_environment
149
46
  end
150
47
 
48
+ if ( exists?( :rails_env ) )
49
+ dd['environment'] ||= {}
50
+ dd['environment']['RAILS_ENV'] = rails_env
51
+ end
52
+
151
53
  dd
152
54
  end
153
-
154
55
  end
56
+
57
+ module TorqueBox
58
+
59
+ def self.load_into( configuration )
60
+ configuration.load do
61
+ # --
62
+
63
+ set( :app_ruby_version, 1.8 ) unless exists?( :app_ruby_version )
64
+ set( :torquebox_home, '/opt/torquebox' ) unless exists?( :torquebox_home )
65
+
66
+ set( :jruby_home, lambda{ "#{torquebox_home}/jruby" } ) unless exists?( :jruby_home )
67
+ set( :jruby_opts, lambda{ "--#{app_ruby_version}" } ) unless exists?( :jruby_opts )
68
+ set( :jruby_bin, lambda{ "#{jruby_home}/bin/jruby #{jruby_opts}" } ) unless exists?( :jruby_bin )
69
+
70
+ set( :jboss_home, lambda{ "#{torquebox_home}/jboss" } ) unless exists?( :jboss_home )
71
+ set( :jboss_control_style, :initid ) unless exists?( :jboss_control_style )
72
+ set( :jboss_init_script, '/etc/init.d/jboss-as-standalone' ) unless exists?( :jboss_init_script )
73
+ set( :jboss_bind_address, '0.0.0.0' ) unless exists?( :jboss_bind_address )
74
+
75
+ set( :bundle_cmd, lambda{ "#{jruby_bin} -S bundle" } ) unless exists?( :bundle_cmd )
76
+ set( :bundle_flags, '' ) unless exists?( :bundle_flags )
77
+
78
+ namespace :deploy do
79
+
80
+ desc "Perform a deployment"
81
+
82
+ task :default do
83
+ update
84
+ end
85
+
86
+ desc "Start TorqueBox Server"
87
+ task :start do
88
+ puts "Starting TorqueBox AS"
89
+ case ( jboss_control_style )
90
+ when :initd
91
+ run "#{jboss_init_script} start"
92
+ when :binscripts
93
+ run "nohup #{jboss_home}/bin/standalone.sh -b #{jboss_bind_address} < /dev/null > /dev/null 2>&1 &"
94
+ end
95
+ end
96
+
97
+ desc "Stop TorqueBox Server"
98
+ task :stop do
99
+ puts "Stopping TorqueBox AS"
100
+ case ( jboss_control_style )
101
+ when :initd
102
+ run "JBOSS_HOME=#{jboss_home} #{jboss_init_script} stop"
103
+ when :binscripts
104
+ run "#{jboss_home}/bin/jboss-admin.sh --connect :shutdown"
105
+ end
106
+ end
107
+
108
+ desc "Restart TorqueBox Server"
109
+ task :restart do
110
+ case ( jboss_control_style )
111
+ when :initd
112
+ puts "Restarting TorqueBox AS"
113
+ puts "JBOSS_HOME=#{jboss_home} #{jboss_init_script} restart"
114
+ when :binscripts
115
+ run "JBOSS_HOME=#{jboss_home} #{jboss_init_script} stop"
116
+ run "nohup #{jboss_home}/bin/standalone.sh -bpublic=#{jboss_bind_address} < /dev/null > /dev/null 2>&1 &"
117
+ end
118
+ end
119
+
120
+ namespace :torquebox do
121
+
122
+ task :info do
123
+ puts "torquebox_home.....#{torquebox_home}"
124
+ puts "jboss_home.........#{jboss_home}"
125
+ puts "jruby_home.........#{jruby_home}"
126
+ puts "bundle command.....#{bundle_cmd}"
127
+ end
128
+
129
+ task :check do
130
+ puts "style #{jboss_control_style}"
131
+ if ( jboss_control_style == :initd )
132
+ run "test -x #{jboss_init_script}", :roles=>[ :app ]
133
+ end
134
+ run "test -d #{jboss_home}", :roles=>[ :app ]
135
+ unless ( [ :initd, :binscripts ].include?( jboss_control_style.to_sym ) )
136
+ fail "invalid jboss_control_style: #{jboss_control_style}"
137
+ end
138
+ end
139
+
140
+ task :deployment_descriptor do
141
+ puts "creating deployment descriptor"
142
+ dd_str = YAML.dump_stream( create_deployment_descriptor(latest_release) )
143
+ dd_file = "#{jboss_home}/standalone/deployments/#{application}-knob.yml"
144
+ cmd = "cat /dev/null > #{dd_file}"
145
+ dd_str.each_line do |line|
146
+ cmd += " && echo \"#{line}\" >> #{dd_file}"
147
+ end
148
+ cmd += " && echo '' >> #{dd_file}"
149
+ run cmd
150
+ run "touch #{dd_file}.dodeploy"
151
+ end
152
+ end
153
+
154
+
155
+ desc "Dump the deployment descriptor"
156
+ task :dump do
157
+ dd = create_deployment_descriptor( latest_release )
158
+ puts dd
159
+ exit
160
+ puts YAML.dump( create_deployment_descriptor( latest_release ) )
161
+ end
162
+
163
+ end
164
+
165
+ before 'deploy:check', 'deploy:torquebox:check'
166
+ after 'deploy:symlink', 'deploy:torquebox:deployment_descriptor'
167
+ end
168
+ end
169
+ end
170
+ end
155
171
 
156
- before 'deploy:check', 'deploy:torquebox:check'
157
- after 'deploy:symlink', 'deploy:torquebox:deployment_descriptor'
158
172
 
173
+ if Capistrano::Configuration.instance
174
+ Capistrano::TorqueBox.load_into(Capistrano::Configuration.instance)
159
175
  end
160
176
 
@@ -1,5 +1,5 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 2.1, February 1999
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 2.1, February 1999
3
3
 
4
4
  Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5
5
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -10,7 +10,7 @@
10
10
  as the successor of the GNU Library Public License, version 2, hence
11
11
  the version number 2.1.]
12
12
 
13
- Preamble
13
+ Preamble
14
14
 
15
15
  The licenses for most software are designed to take away your
16
16
  freedom to share and change it. By contrast, the GNU General Public
@@ -112,7 +112,7 @@ modification follow. Pay close attention to the difference between a
112
112
  former contains code derived from the library, whereas the latter must
113
113
  be combined with the library in order to run.
114
114
 
115
- GNU LESSER GENERAL PUBLIC LICENSE
115
+ GNU LESSER GENERAL PUBLIC LICENSE
116
116
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
117
 
118
118
  0. This License Agreement applies to any software library or other
@@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
146
146
  on the Library (independent of the use of the Library in a tool for
147
147
  writing it). Whether that is true depends on what the Library does
148
148
  and what the program that uses the Library does.
149
-
149
+
150
150
  1. You may copy and distribute verbatim copies of the Library's
151
151
  complete source code as you receive it, in any medium, provided that
152
152
  you conspicuously and appropriately publish on each copy an
@@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
432
432
  of all derivatives of our free software and of promoting the sharing
433
433
  and reuse of software generally.
434
434
 
435
- NO WARRANTY
435
+ NO WARRANTY
436
436
 
437
437
  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438
438
  WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@@ -455,7 +455,7 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455
455
  SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456
456
  DAMAGES.
457
457
 
458
- END OF TERMS AND CONDITIONS
458
+ END OF TERMS AND CONDITIONS
459
459
 
460
460
  How to Apply These Terms to Your New Libraries
461
461
 
@@ -500,5 +500,3 @@ necessary. Here is a sample; alter the names:
500
500
  Ty Coon, President of Vice
501
501
 
502
502
  That's all there is to it!
503
-
504
-
@@ -0,0 +1,50 @@
1
+ # Copyright 2008-2011 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
+
18
+ require 'spec_helper'
19
+ require 'torquebox-capistrano-support'
20
+
21
+ describe Capistrano::TorqueBox, "loaded into a configuration" do
22
+
23
+ before do
24
+ @configuration = Capistrano::Configuration.new
25
+ Capistrano::TorqueBox.load_into(@configuration)
26
+ end
27
+
28
+ it "should define app_ruby_version" do
29
+ @configuration.exists?( :app_ruby_version ).should be_true
30
+ end
31
+
32
+ it "should default app_ruby_version to 1.8" do
33
+ @configuration.fetch( :app_ruby_version ).should == 1.8
34
+ end
35
+
36
+ it "should allow default override for app_ruby_version" do
37
+ @configuration.set( :app_ruby_version, 1.9 )
38
+ @configuration.fetch( :app_ruby_version ).should == 1.9
39
+ end
40
+
41
+ it "should create a deployment descriptor" do
42
+ @configuration.should respond_to(:create_deployment_descriptor)
43
+ end
44
+
45
+ it "should set RAILS_ENV based on :rails_env" do
46
+ @configuration.set( :rails_env, 'development' )
47
+ @configuration.create_deployment_descriptor('/path/to/app')['environment']['RAILS_ENV'].should == 'development'
48
+ end
49
+
50
+ end
@@ -0,0 +1,19 @@
1
+ # Copyright 2008-2011 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
+
18
+
19
+ require 'capistrano-spec'
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquebox-capistrano-support
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.1
4
+ prerelease: 6
5
+ version: 2.0.0.beta1
6
6
  platform: ruby
7
7
  authors:
8
8
  - The TorqueBox Team
@@ -10,10 +10,52 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-09 00:00:00 -04:00
14
- default_executable:
15
- dependencies: []
16
-
13
+ date: 2011-12-02 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: jruby-openssl
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.7.4
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: capistrano
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.9.0
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: capistrano-spec
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.0
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - "="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.7.0
57
+ type: :development
58
+ version_requirements: *id004
17
59
  description: ""
18
60
  email:
19
61
  - torquebox-dev@torquebox.org
@@ -28,8 +70,9 @@ files:
28
70
  - lib/org.torquebox.capistrano-support.rb
29
71
  - lib/torquebox-capistrano-support.rb
30
72
  - lib/torquebox/capistrano/recipes.rb
31
- has_rdoc: true
32
- homepage: http://www.torquebox.org/torquebox-capistrano-support/
73
+ - spec/recipes_spec.rb
74
+ - spec/spec_helper.rb
75
+ homepage: http://www.torquebox.org/torquebox-gems-parent/torquebox-capistrano-support/
33
76
  licenses:
34
77
  - lgpl
35
78
  post_install_message:
@@ -46,15 +89,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
89
  required_rubygems_version: !ruby/object:Gem::Requirement
47
90
  none: false
48
91
  requirements:
49
- - - ">="
92
+ - - ">"
50
93
  - !ruby/object:Gem::Version
51
- version: "0"
94
+ version: 1.3.1
52
95
  requirements: []
53
96
 
54
97
  rubyforge_project:
55
- rubygems_version: 1.5.1
98
+ rubygems_version: 1.8.9
56
99
  signing_key:
57
100
  specification_version: 3
58
101
  summary: TorqueBox Capistrano Support
59
- test_files: []
60
-
102
+ test_files:
103
+ - spec/recipes_spec.rb