Module: Capistrano::TorqueBox Private
- Defined in:
- lib/torquebox/capistrano/recipes.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
Class Method Details
.load_into(configuration) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/torquebox/capistrano/recipes.rb', line 66 def self.load_into( configuration ) configuration.load do # -- set( :torquebox_home, '/opt/torquebox' ) unless exists?( :torquebox_home ) set( :jruby_home, lambda{ "#{torquebox_home}/jruby" } ) unless exists?( :jruby_home ) if exists?( :app_ruby_version ) && !exists?( :jruby_opts ) set( :jruby_opts, lambda{ "--#{app_ruby_version}" } ) end set( :jruby_bin, lambda{ "#{jruby_home}/bin/jruby #{jruby_opts if exists?( :jruby_opts )}" } ) unless exists?( :jruby_bin ) set( :jboss_home, lambda{ "#{torquebox_home}/jboss" } ) unless exists?( :jboss_home ) set( :jboss_control_style, :initd ) unless exists?( :jboss_control_style ) set( :jboss_init_script, '/etc/init.d/jboss-as-standalone' ) unless exists?( :jboss_init_script ) set( :jboss_runit_script, '/etc/service/torquebox/run' ) unless exists?( :jboss_runit_script) set( :jboss_upstart_script, '/etc/init/torquebox.conf' ) unless exists?( :jboss_upstart_script) set( :jboss_bind_address, '0.0.0.0' ) unless exists?( :jboss_bind_address ) set( :bundle_cmd, lambda{ "#{jruby_bin} -S bundle" } ) unless exists?( :bundle_cmd ) set( :bundle_flags, '' ) unless exists?( :bundle_flags ) set( :torquebox_app_name, lambda{ application } ) unless exists?( :torquebox_app_name ) namespace :deploy do desc "Restart Application" task :restart, :except => { :no_release => true } do run "touch #{jboss_home}/standalone/deployments/#{torquebox_app_name}-knob.yml.dodeploy" end namespace :torquebox do desc "Start TorqueBox Server" task :start, :except => { :no_release => true } do puts "Starting TorqueBox AS" case ( jboss_control_style ) when :initd run "#{sudo} #{jboss_init_script} start" when :binscripts run "nohup #{jboss_home}/bin/standalone.sh -b #{jboss_bind_address} < /dev/null > /dev/null 2>&1 &" when :runit run "#{sudo} sv start torquebox" when :upstart run "#{sudo} service torquebox start" end end desc "Stop TorqueBox Server" task :stop, :except => { :no_release => true } do puts "Stopping TorqueBox AS" case ( jboss_control_style ) when :initd run "#{sudo} JBOSS_HOME=#{jboss_home} #{jboss_init_script} stop" when :binscripts run "#{jboss_home}/bin/jboss-cli.sh --connect :shutdown" when :runit run "#{sudo} sv stop torquebox" when :upstart run "#{sudo} service torquebox stop" end end desc "Restart TorqueBox Server" task :restart, :except => { :no_release => true } do case ( jboss_control_style ) when :initd puts "Restarting TorqueBox AS" run "#{sudo} JBOSS_HOME=#{jboss_home} #{jboss_init_script} restart" when :binscripts run "#{jboss_home}/bin/jboss-cli.sh --connect :shutdown" run "nohup #{jboss_home}/bin/standalone.sh -bpublic=#{jboss_bind_address} < /dev/null > /dev/null 2>&1 &" when :runit puts "Restarting TorqueBox AS" run "#{sudo} sv restart torquebox" when :upstart puts "Restarting TorqueBox AS" run "#{sudo} service torquebox restart" end end task :info, :except => { :no_release => true } do puts "torquebox_home.....#{torquebox_home}" puts "jboss_home.........#{jboss_home}" puts "jruby_home.........#{jruby_home}" puts "bundle command.....#{bundle_cmd}" end task :check, :except => { :no_release => true } do puts "style #{jboss_control_style}" case jboss_control_style when :initd run "test -x #{jboss_init_script}", :roles=>[ :app ] when :runit run "test -x #{jboss_runit_script}", :roles=>[ :app ] when :upstart run "test -x #{jboss_upstart_script}", :roles=>[ :app ] end run "test -d #{jboss_home}", :roles=>[ :app ] unless ( [ :initd, :binscripts, :runit, :upstart ].include?( jboss_control_style.to_sym ) ) fail "invalid jboss_control_style: #{jboss_control_style}" end end task :deployment_descriptor, :except => { :no_release => true } do puts "creating deployment descriptor" dd_str = YAML.dump_stream( create_deployment_descriptor(current_path) ) dd_file = "#{jboss_home}/standalone/deployments/#{torquebox_app_name}-knob.yml" cmd = "cat /dev/null > #{dd_file}" dd_str.each_line do |line| cmd += " && echo \"#{line}\" >> #{dd_file}" end cmd += " && echo '' >> #{dd_file}" run cmd end task :rollback_deployment_descriptor do puts "rolling back deployment descriptor" dd_str = YAML.dump_stream( create_deployment_descriptor(previous_release) ) dd_file = "#{jboss_home}/standalone/deployments/#{application}-knob.yml" cmd = "cat /dev/null > #{dd_file}" dd_str.each_line do |line| cmd += " && echo \"#{line}\" >> #{dd_file}" end cmd += " && echo '' >> #{dd_file}" run cmd end end desc "Dump the deployment descriptor" task :dump, :except => { :no_release => true } do dd = create_deployment_descriptor( current_path ) puts dd exit puts YAML.dump( create_deployment_descriptor( current_path ) ) end desc "Restart application with zero downtime" task :restart_zero_downtime do run "touch #{current_path}/tmp/restart-all.txt" end desc "Deploy application with zero downtime" task :deploy_zero_downtime do deploy.update restart_zero_downtime end end before 'deploy:check', 'deploy:torquebox:check' after 'deploy:create_symlink', 'deploy:torquebox:deployment_descriptor' after 'deploy:rollback:revision', 'deploy:torquebox:rollback_deployment_descriptor' end end |