Skip to content

Instantly share code, notes, and snippets.

@kyleburton
Created August 26, 2010 14:22
Show Gist options
  • Save kyleburton/551478 to your computer and use it in GitHub Desktop.
Save kyleburton/551478 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__),'..','src','main','ruby','util')
require File.join(File.dirname(__FILE__),'deploy-check')
class ClojureServiceDeployer < ServiceUtils
def run
unless File.exist? release_jar_file
unless system("mvn assembly:assembly")
raise "Error building assembly jar #{release_jar_file}"
end
unless File.exist? release_jar_file
raise "Error mvn assembly didn't build the target jar file: #{release_jar_file}"
end
end
hosts_to_process.each do |hname,cfg|
@options[:host] = cfg[:hostname]
log4j_conf = assert_local_file :log4j, env_res_file("log4j.properties")
db_conf = assert_local_file :db_conf, env_res_file("database.properties")
install_path = @options[:install_path] || cfg[:install_path]
release_dir = "#{install_path}/releases/#{@release_directory_dstamp}"
path_to_jar = release_jar_file
ensure_remote_directory release_dir
copy_to_remote path_to_jar, "#{release_dir}/#{release_jar_name}"
remote "ln -s #{release_dir}/#{release_jar_name} #{release_dir}/the-clj-service.jar"
ensure_remote_directory "#{release_dir}/config"
copy_to_remote log4j_conf, "#{release_dir}/config/log4j.properties"
copy_to_remote db_conf, "#{release_dir}/config/database.properties"
File.open( '/tmp/foo', 'w') do |f|
f.puts "our-app.the-clj-service.version=#{@release_directory_dstamp}"
f.puts "our-app.the-clj-service.hostname=#{@options[:host]}"
f.puts "our-app.the-clj-service.pom.version=#{jar_version}"
end
copy_to_remote '/tmp/foo', "#{release_dir}/config/the-clj-service.properties"
remote "ln -s #{release_dir} #{current_symlink(install_path)}.new"
apply_fs_attrs "#{current_symlink(install_path)}.new", :owner => @options[:owner], :perms => '755'
remote "mv -T #{current_symlink(install_path)}.new #{current_symlink(install_path)}"
remote "/etc/init.d/the-clj-serviced restart"
checker = DeployCheck.new @release_directory_dstamp, @options
checker.run hname, true
end
end
end
if __FILE__ == $0
ClojureServiceDeployer.main
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment