tomcap 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ tomcap-*.gem
3
+ github-test.rb
@@ -0,0 +1,52 @@
1
+ = tomcap
2
+
3
+ == DESCRIPTION:
4
+
5
+ Capistrano tasks which allow you to quickly and easily deploy Java WAR files located in remote repositories (currently Artifactory repos) to a running Tomcat container.
6
+
7
+ == REQUIREMENTS:
8
+
9
+ * capistrano (http://capify.org)
10
+ * Access to an Artifactory repository
11
+ * Some Java code you want to deploy (in WAR format) hosted in your Artifactory Maven repo.
12
+ * A running Tomcat container. The manager port does not need to be open from your local machine. (Otherwise you could probably deploy just
13
+ as easily without using this plugin!)
14
+
15
+ == INSTALLATION:
16
+
17
+ $ gem sources -a http://gems.github.com/ (if you havn't already, which is unlikely)
18
+ $ gem install ienders-tomcap
19
+
20
+ == USAGE:
21
+
22
+ = Include in capistrano
23
+
24
+ In your deploy.rb, simply include this line at the top:
25
+
26
+ require 'tomcap/recipes'
27
+
28
+ = Set your configuration parameters
29
+
30
+ set :tomcat_user, "..."
31
+ set :tomcat_pass, "..."
32
+
33
+ set :mvn_repo_user, "..."
34
+ set :mvn_repo_pass, "..."
35
+
36
+ set :mvn_repository, "libs-snapshots-local"
37
+ set :mvn_war_group_id, "com.mycompany"
38
+ set :mvn_war_artifact_id, "my-application"
39
+ set :mvn_war_version, "1.0-SNAPSHOT"
40
+
41
+ = Assign a java role to all servers hosting your app
42
+
43
+ role :java, 'myhost.com'
44
+
45
+ = Deploy
46
+
47
+ $ cap <environment> deploy:java
48
+
49
+ == AUTHOR:
50
+
51
+ Ian Enders
52
+ addictedtoian.com
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name = "tomcap"
7
+ gemspec.summary = "Tomcat deployment with Capistrano"
8
+ gemspec.description = "Capistrano tasks which allow you to quickly and easily deploy Java WAR files located in remote repositories (currently Artifactory repos) to a running Tomcat container."
9
+ gemspec.email = "ian.enders@gmail.com"
10
+ gemspec.homepage = "http://github.com/ienders/tomcap"
11
+ gemspec.authors = ["Ian Enders"]
12
+ end
13
+ rescue LoadError
14
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
15
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.3
@@ -0,0 +1,97 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :deploy do
4
+ task :setup_java, :roles => :java do
5
+ run "mkdir -p #{shared_path}/cached_java_copy"
6
+ end
7
+
8
+
9
+ desc <<-DESC
10
+ Deploy Java WAR to a running Tomcat container.
11
+
12
+ Required Arguments (examples specified):
13
+ set :tomcat_user, "manager"
14
+ set :tomcat_pass, "password"
15
+ set :mvn_repo_user, "artifactory"
16
+ set :mvn_repo_pass, "password"
17
+ set :mvn_repository, "libs-releases-local"
18
+ set :mvn_war_group_id, "com.mycompany"
19
+ set :mvn_war_artifact_id, "my-application"
20
+ set :mvn_war_version, "1.0-SNAPSHOT"
21
+
22
+ Optional Arguments (defaults specified):
23
+ set :tomcat_url, "http://localhost:8080"
24
+ set :artifactory_url, "http://localhost:8080/artifactory"
25
+ set :tomcat_initd_script, "/etc/init.d/tomcat"
26
+ DESC
27
+ task :java, :roles => :java do
28
+ require 'net/http'
29
+
30
+ raise ArgumentError, "Must set tomcat_user" unless tomcat_user = fetch(:tomcat_user, nil)
31
+ raise ArgumentError, "Must set tomcat_pass" unless tomcat_pass = fetch(:tomcat_pass, nil)
32
+ raise ArgumentError, "Must set mvn_repo_user" unless mvn_repo_user = fetch(:mvn_repo_user, nil)
33
+ raise ArgumentError, "Must set mvn_repo_pass" unless mvn_repo_pass = fetch(:mvn_repo_pass, nil)
34
+ raise ArgumentError, "Must set mvn_repository" unless mvn_repository = fetch(:mvn_repository, nil)
35
+ raise ArgumentError, "Must set mvn_war_group_id" unless mvn_war_group_id = fetch(:mvn_war_group_id, nil)
36
+ raise ArgumentError, "Must set mvn_war_artifact_id" unless mvn_war_artifact_id = fetch(:mvn_war_artifact_id, nil)
37
+ raise ArgumentError, "Must set mvn_war_version" unless mvn_war_version = fetch(:mvn_war_version, nil)
38
+
39
+ war_file = "#{mvn_war_artifact_id}-#{mvn_war_version}.war"
40
+
41
+ run "rm -rf #{shared_path}/cached_java_copy/#{war_file}"
42
+
43
+ tomcat_url = fetch(:tomcat_url, "http://localhost:8080")
44
+ artifactory_url = fetch(:artifactory_url, "http://localhost:8080/artifactory")
45
+
46
+ war_path = "#{artifactory_url}/#{mvn_repository}/#{mvn_war_group_id.gsub(/\./, '/')}/#{mvn_war_artifact_id}/#{mvn_war_version}"
47
+
48
+ run <<-CMD
49
+ cd #{shared_path}/cached_java_copy &&
50
+ wget #{war_path}/#{war_file} --user=#{mvn_repo_user} --password=#{mvn_repo_pass}
51
+ CMD
52
+
53
+ manager_url = "#{tomcat_url}/manager"
54
+ context_path = "/#{mvn_war_artifact_id}-#{mvn_war_version}"
55
+
56
+ run "curl -v -u #{tomcat_user}:#{tomcat_pass} #{manager_url}/undeploy?path=#{context_path}"
57
+ run "curl -v -u #{tomcat_user}:#{tomcat_pass} \"#{manager_url}/deploy?path=#{context_path}&war=file:#{shared_path}/cached_java_copy/#{war_file}\""
58
+ end
59
+
60
+ namespace :tomcat do
61
+ desc "stop tomcat"
62
+ task :stop, :roles => :java do
63
+ sudo "#{tomcat_initd_script} stop ; echo '' "
64
+ end
65
+ desc "start tomcat"
66
+ task :start, :roles => :java do
67
+ sudo "#{tomcat_initd_script} start"
68
+ end
69
+ desc "kill tomcat processes"
70
+ task :kill, :roles => :java do
71
+ sudo "ps -ef | grep 'tomcat' | grep -v 'grep' | awk '{print $2}'| xargs -i kill {} ; echo ''"
72
+ end
73
+ desc "view running tomcat processes"
74
+ task :processes, :roles => :java do
75
+ puts " ********************\n * running tomcat processes: "
76
+ sudo "ps -ef | grep 'tomcat'"
77
+ end
78
+ desc "restart tomcat"
79
+ task :restart, :roles => :java do
80
+ wait_time = 60
81
+ processes
82
+ puts " ********************\n * tomcat stopping (with #{wait_time} sec wait)..."
83
+ stop
84
+ sleep wait_time
85
+ processes
86
+ puts " ********************\n * tomcat restarting..."
87
+ start
88
+ processes
89
+ end
90
+ end
91
+
92
+ end
93
+
94
+
95
+ before "deploy:java", "deploy:setup_java"
96
+
97
+ end
@@ -0,0 +1,41 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{tomcap}
8
+ s.version = "1.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ian Enders"]
12
+ s.date = %q{2010-08-12}
13
+ s.description = %q{Capistrano tasks which allow you to quickly and easily deploy Java WAR files located in remote repositories (currently Artifactory repos) to a running Tomcat container.}
14
+ s.email = %q{ian.enders@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.txt"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "README.txt",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "lib/tomcap/recipes.rb",
24
+ "tomcap.gemspec"
25
+ ]
26
+ s.homepage = %q{http://github.com/ienders/tomcap}
27
+ s.rdoc_options = ["--charset=UTF-8"]
28
+ s.require_paths = ["lib"]
29
+ s.rubygems_version = %q{1.3.7}
30
+ s.summary = %q{Tomcat deployment with Capistrano}
31
+
32
+ if s.respond_to? :specification_version then
33
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37
+ else
38
+ end
39
+ else
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tomcap
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 3
10
+ version: 1.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Ian Enders
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-12 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Capistrano tasks which allow you to quickly and easily deploy Java WAR files located in remote repositories (currently Artifactory repos) to a running Tomcat container.
23
+ email: ian.enders@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.txt
30
+ files:
31
+ - .gitignore
32
+ - README.txt
33
+ - Rakefile
34
+ - VERSION
35
+ - lib/tomcap/recipes.rb
36
+ - tomcap.gemspec
37
+ has_rdoc: true
38
+ homepage: http://github.com/ienders/tomcap
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Tomcat deployment with Capistrano
71
+ test_files: []
72
+