torquebox-remote-deployer 0.1.1 → 0.1.2.pre1

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.
data/README.md CHANGED
@@ -29,7 +29,7 @@ You'll need to configure it like this:
29
29
  hostname "localhost"
30
30
  port "2222"
31
31
  user "vagrant"
32
- key "#{ENV["GEM_HOME"]}/gems/vagrant-0.8.7/keys/vagrant"
32
+ key "~/.vagrant.d/insecure_private_key"
33
33
  sudo true
34
34
  end
35
35
 
@@ -43,9 +43,9 @@ its root directory; like this:
43
43
 
44
44
  $ rake torquebox:remote:exec["bundle install --path vendor/bundle"]
45
45
 
46
- Now you can to do more useful things like running migrations:
46
+ Or if you ran `bundle --deployment` before creating your Knob you can just jump right in and run something more useful like your migrations:
47
47
 
48
- $ rake torquebox:remote:exec["rake db:migrate RAILS_ENV=production"]
48
+ $ rake torquebox:remote:exec["bundle exec rake db:migrate"]
49
49
 
50
50
  After the `exec` tasks are complete, you can deploy the Knob to the TorqueBox server.
51
51
 
@@ -53,8 +53,29 @@ After the `exec` tasks are complete, you can deploy the Knob to the TorqueBox se
53
53
 
54
54
  This task works just like the `torquebox:deploy:archive` task, but remotely.
55
55
 
56
+ ## Deploying to Multiple Environments
57
+
58
+ The `torquebox-remote-deployer` gem defaults to production mode, so all the examples shown above will execute with your `production` Bundler group and db config. But it's most likely that you will want to deploy to a staging or test environment before deploying to production. In that case, you'll need a config file for each one. In each config file, you can specify the RACK_ENV or RAILS_ENV like this:
59
+
60
+ TorqueBox::RemoteDeploy.configure do
61
+ torquebox_home "/opt/torquebox"
62
+ hostname "localhost"
63
+ port "2222"
64
+ user "vagrant"
65
+ key "~/.vagrant.d/insecure_private_key"
66
+
67
+ # set the RAILS_ENV on the remote server
68
+ rails_env "staging"
69
+ end
70
+
71
+ Then you can deploy with the `TB_REMOTE_FILE` environment variable set like this:
72
+
73
+ $ export TB_REMOTE_FILE=config/torquebox_remote.staging.rb
74
+ $ rake torquebox:remote:stage
75
+
76
+ You can name the config file whatever you'd like, and you can have one per environment -- but use the same Rake tasks.
77
+
56
78
  ## TODO
57
79
 
58
80
  * Make it friendly to remote Windows targets (already works on Windows source machines).
59
- * Support deploying to mutliple servers (config would look like multi-hosts in a Vagrantfile)
60
81
  * Support deploying over FTP or SFTP in addition to SCP/SSH.
@@ -52,11 +52,10 @@ module TorqueBox
52
52
  def exec_ruby(archive_file, cmd)
53
53
  with_config(archive_file) do |config, app_name|
54
54
  unless config.local
55
- # TODO set RACK_ENV based on env var, and default to production
56
55
  ssh_exec(config, "cd #{config.torquebox_home}/stage/#{app_name}",
57
56
  "export PATH=$PATH:#{config.torquebox_home}/jruby/bin",
58
- "export RAILS_ENV=production",
59
- "export RACK_ENV=production",
57
+ "export RAILS_ENV=#{config.rack_env}",
58
+ "export RACK_ENV=#{config.rack_env}",
60
59
  "#{config.torquebox_home}/jruby/bin/jruby -S #{cmd}")
61
60
  else
62
61
  # not sure what to do here yet
@@ -71,13 +70,12 @@ module TorqueBox
71
70
  end
72
71
 
73
72
  def do_deploy(config, app_name)
74
- # TODO set RACK_ENV based on env var, and default to production
75
73
  knob_yml = <<-YAML
76
74
  application:
77
75
  root: #{config.jboss_home}/standalone/deployments/#{app_name}.knob
78
76
  environment:
79
- RACK_ENV: production
80
- RAILS_ENV: production
77
+ RACK_ENV: #{config.rack_env}
78
+ RAILS_ENV: #{config.rack_env}
81
79
  YAML
82
80
 
83
81
  unless config.local
@@ -88,6 +86,7 @@ module TorqueBox
88
86
  ssh_exec(config, "touch #{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml.dodeploy")
89
87
  else
90
88
  # todo copy temp file to somewhere
89
+ File.open("#{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml", "w") {}
91
90
  File.open("#{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml.dodeploy", "w") {}
92
91
  end
93
92
  end
@@ -143,7 +142,7 @@ module TorqueBox
143
142
  end
144
143
 
145
144
  def read_config
146
- config_file = ENV["CONFIG_FILE"] || ENV["config_file"] || "config/torquebox_remote.rb"
145
+ config_file = ENV["TB_REMOTE_FILE"] || ENV["tb_remote_file"] || "config/torquebox_remote.rb"
147
146
  eval(File.read(config_file)).configurations
148
147
  end
149
148
  end
@@ -202,11 +201,27 @@ module TorqueBox
202
201
  def host(&block)
203
202
  @configs << RemoteDeploy.new(block).config
204
203
  end
204
+
205
+ def rails_env(env)
206
+ @config.rack_env = env
207
+ end
208
+
209
+ def rack_env(env)
210
+ @config.rack_env = env
211
+ end
205
212
  end
206
213
 
207
214
  class RemoteConfig
208
215
  attr_accessor :hostname, :port, :user, :key, :torquebox_home, :sudo, :local
209
216
 
217
+ def rack_env=(env)
218
+ @rack_env = env
219
+ end
220
+
221
+ def rack_env
222
+ @rack_env || "production"
223
+ end
224
+
210
225
  def jboss_home=(jbh)
211
226
  @jboss_home = jbh
212
227
  end
@@ -4,4 +4,6 @@ TorqueBox::RemoteDeploy.configure do
4
4
  port "2222"
5
5
  user "torquebox"
6
6
  key "~/.ssh/id_rsa.pub"
7
+ rails_env "production"
8
+ rack_env "production"
7
9
  end
@@ -8,14 +8,14 @@ describe TorqueBox::RemoteDeployUtils do
8
8
 
9
9
  describe ".stage" do
10
10
  it "stages one host" do
11
- ENV["config_file"] = File.join(File.dirname(__FILE__), "fixtures/simple_torquebox_remote.rb")
11
+ ENV["tb_remote_file"] = File.join(File.dirname(__FILE__), "fixtures/simple_torquebox_remote.rb")
12
12
  @util.stub(:ssh_exec)
13
13
  @util.should_receive(:scp_upload).with(anything(), "myapp.knob", "/opt/torquebox/stage/myapp.knob")
14
14
  @util.stage("myapp.knob")
15
15
  end
16
16
 
17
17
  it "stages two hosts" do
18
- ENV["config_file"] = File.join(File.dirname(__FILE__), "fixtures/multihost_torquebox_remote.rb")
18
+ ENV["tb_remote_file"] = File.join(File.dirname(__FILE__), "fixtures/multihost_torquebox_remote.rb")
19
19
  @util.stub(:ssh_exec)
20
20
  @util.should_receive(:scp_upload).with(anything(), "myapp.knob", "/my/tb/dir/stage/myapp.knob")
21
21
  @util.should_receive(:scp_upload).with(anything(), "myapp.knob", "/opt/torquebox/stage/myapp.knob")
@@ -24,7 +24,7 @@ describe TorqueBox::RemoteDeployUtils do
24
24
 
25
25
  context "local" do
26
26
  it "stages" do
27
- ENV["config_file"] = File.join(File.dirname(__FILE__), "fixtures/local_torquebox_remote.rb")
27
+ ENV["tb_remote_file"] = File.join(File.dirname(__FILE__), "fixtures/local_torquebox_remote.rb")
28
28
  @util.stage("myapp.knob") # does nothing
29
29
  end
30
30
  end
@@ -41,10 +41,13 @@ describe TorqueBox::RemoteDeployUtils do
41
41
  end
42
42
 
43
43
  it "deploys" do
44
- ENV["config_file"] = File.join(File.dirname(__FILE__), "fixtures/local_torquebox_remote.rb")
44
+ ENV["tb_remote_file"] = File.join(File.dirname(__FILE__), "fixtures/local_torquebox_remote.rb")
45
45
  @util.deploy(File.join(File.dirname(__FILE__), "fixtures/myapp.knob"))
46
46
  File.exists?("#{deploy_dir}/myapp.knob").should == true
47
- File.exists?("#{deploy_dir}/myapp.knob.dodeploy").should == true
47
+
48
+ # this isn't really testing the real deal yet
49
+ File.exists?("#{deploy_dir}/myapp-knob.yml").should == true
50
+ File.exists?("#{deploy_dir}/myapp-knob.yml.dodeploy").should == true
48
51
  end
49
52
 
50
53
  def deploy_dir
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "torquebox-remote-deployer"
6
- s.version = "0.1.1"
6
+ s.version = "0.1.2.pre1"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Joe Kutner"]
9
9
  s.email = ["jpkutner@gmail.com"]
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquebox-remote-deployer
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.1
4
+ prerelease: 6
5
+ version: 0.1.2.pre1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Joe Kutner
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-03-24 00:00:00 Z
13
+ date: 2012-05-08 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jruby-openssl
@@ -108,9 +108,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  none: false
110
110
  requirements:
111
- - - ">="
111
+ - - ">"
112
112
  - !ruby/object:Gem::Version
113
- version: "0"
113
+ version: 1.3.1
114
114
  requirements: []
115
115
 
116
116
  rubyforge_project: torquebox-remote-deployer