Permalink
Browse files

ability to pick the archive name from an environment variable

  • Loading branch information...
1 parent b44f71c commit d55c4831f8ba2ee7e78bacc1ae7108817e24eab7 @pungoyal pungoyal committed Sep 8, 2012
View
@@ -1,3 +1,4 @@
*.gem
.idea
-tmp
+tmp
+*.lock
@@ -7,13 +7,13 @@
desc "Upload this application to the remote server as an archive file"
task :stage => ["torquebox:archive"] do
- archive_name = TorqueBox::DeployUtils.archive_name
+ archive_name = TorqueBox::RemoteDeployUtils.archive_name
TorqueBox::RemoteDeployUtils.stage(archive_name)
end
desc "Execute Ruby commands against the staged archive file"
task :exec, [:cmd] do |t, args|
- cmd = args[:cmd]
+ cmd = args[:cmd]
archive_name = TorqueBox::DeployUtils.archive_name
TorqueBox::RemoteDeployUtils.exec_ruby(archive_name, cmd)
end
@@ -63,6 +63,10 @@ def exec_ruby(archive_file, cmd)
end
end
+ def archive_name
+ TorqueBox::DeployUtils.normalize_archive_name(ENV['name'] || TorqueBox::DeployUtils.archive_name)
+ end
+
private
def prefix(config)
@@ -86,8 +90,8 @@ def do_deploy(config, app_name)
ssh_exec(config, "touch #{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml.dodeploy")
else
# todo copy temp file to somewhere
- File.open("#{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml", "w") {}
- File.open("#{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml.dodeploy", "w") {}
+ File.open("#{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml", "w") { }
+ File.open("#{config.jboss_home}/standalone/deployments/#{app_name}-knob.yml.dodeploy", "w") { }
end
end
@@ -135,7 +139,7 @@ def ssh_exec(config, *cmd)
def scp_upload(config, local_file, remote_file)
unless config.local
Net::SCP.upload!(config.hostname, config.user, local_file, remote_file,
- :ssh => {:port => config.port, :keys => [config.key]}
+ :ssh => { :port => config.port, :keys => [config.key] }
) do |ch, name, sent, total|
print "\rCopying #{name}: #{sent}/#{total}"
end
@@ -158,7 +162,7 @@ def self.configure(&blk)
end
def initialize(blk)
- @config = RemoteConfig.new
+ @config = RemoteConfig.new
@configs = []
instance_eval &blk
end
@@ -235,10 +239,10 @@ def jboss_home
end
def initialize
- @user = "torquebox"
+ @user = "torquebox"
@torquebox_home = "/opt/torquebox"
- @sudo = false
- @local = false
+ @sudo = false
+ @local = false
end
end
end
@@ -25,11 +25,23 @@
context "local" do
it "stages" do
ENV["tb_remote_file"] = File.join(File.dirname(__FILE__), "fixtures/local_torquebox_remote.rb")
- @util.stage("myapp.knob") # does nothing
+ @util.stage("myapp.knob") # does nothing
end
end
end
+ describe "archive name" do
+ it "should pick it up from environment variable" do
+ ENV["name"] = "archive-file-to-be-deployed"
+ @util.archive_name.should == "archive-file-to-be-deployed.knob"
+ ENV["name"] = nil
+ end
+
+ it "should pick it up torquebox deploy utils if 'name' environment variable is not set" do
+ @util.archive_name.should == "#{File.basename(Dir.pwd)}.knob"
+ end
+ end
+
describe ".deploy" do
context "local" do
before do
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = "torquebox-remote-deployer"
- s.version = "0.1.2.pre2"
+ s.version = "0.1.2.pre3"
s.platform = "java"
s.authors = ["Joe Kutner"]
s.email = ["jpkutner@gmail.com"]
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_dependency "jruby-openssl"

0 comments on commit d55c483

Please sign in to comment.