capitomcat 0.0.3 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/LICENSE.md +202 -0
- data/README.md +81 -258
- data/capitomcat.gemspec +13 -11
- data/examples/native/Gemfile +4 -0
- data/examples/native/README.md +1 -0
- data/examples/native/lib/native/application.rb +80 -0
- data/examples/native/lib/native/tasks/tomcat_webapp.cap +26 -0
- data/examples/native/lib/native.rb +3 -0
- data/examples/native/templates/context.xml.erb +1 -0
- data/examples/recipe/customizing/Capfile +26 -0
- data/examples/recipe/customizing/README.md +1 -0
- data/examples/recipe/customizing/config/deploy/dev.rb +39 -0
- data/examples/recipe/customizing/config/deploy/production.rb +39 -0
- data/examples/recipe/customizing/config/deploy/staging.rb +39 -0
- data/examples/recipe/customizing/config/deploy.rb +40 -0
- data/examples/recipe/customizing/lib/capistrano/tasks/tomcat_webapp.cap +49 -0
- data/examples/recipe/customizing/templates/context.xml.erb +1 -0
- data/examples/recipe/multistage/Capfile +26 -0
- data/examples/recipe/multistage/README.md +1 -0
- data/examples/recipe/multistage/config/deploy/dev.rb +39 -0
- data/examples/recipe/multistage/config/deploy/production.rb +39 -0
- data/examples/recipe/multistage/config/deploy/staging.rb +39 -0
- data/examples/recipe/multistage/config/deploy.rb +40 -0
- data/examples/recipe/multistage/lib/capistrano/tasks/tomcat_webapp.cap +23 -0
- data/examples/recipe/multistage/templates/context.xml.erb +1 -0
- data/examples/recipe/singlestage/Capfile +26 -0
- data/examples/recipe/singlestage/README.md +1 -0
- data/examples/recipe/singlestage/lib/capistrano/tasks/tomcat_webapp.cap +29 -0
- data/examples/recipe/singlestage/templates/context.xml.erb +1 -0
- data/lib/capitomcat/deploy.rb +1 -0
- data/lib/capitomcat/tasks/deploy.cap +226 -0
- data/lib/capitomcat/version.rb +3 -0
- data/lib/capitomcat.rb +3 -104
- data/template/context.xml.erb +1 -0
- metadata +62 -31
- data/Rakefile +0 -5
- data/examples/README.md +0 -1
- data/examples/multistage/Capfile +0 -25
- data/examples/multistage/README.md +0 -1
- data/examples/multistage/config/deploy/dev.rb +0 -4
- data/examples/multistage/config/deploy/prod.rb +0 -4
- data/examples/multistage/config/deploy/stg.rb +0 -4
- data/examples/multistage/config/deploy.rb +0 -16
- data/examples/multistage/template/context.xml.erb +0 -1
- data/examples/singlestage/Capfile +0 -24
- data/examples/singlestage/config/deploy.rb +0 -16
- data/examples/singlestage/template/context.xml.erb +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'capistrano/all'
|
|
3
|
+
require 'capistrano/setup'
|
|
4
|
+
require 'capistrano/deploy'
|
|
5
|
+
|
|
6
|
+
class Application
|
|
7
|
+
|
|
8
|
+
def self.doCap
|
|
9
|
+
|
|
10
|
+
set :stage, :dev
|
|
11
|
+
|
|
12
|
+
set :format, :pretty
|
|
13
|
+
set :log_level, :info
|
|
14
|
+
set :pty, true
|
|
15
|
+
set :use_sudo, true
|
|
16
|
+
|
|
17
|
+
# Server definition section
|
|
18
|
+
role :app, %w{deploy@dev01 deploy@dev02}
|
|
19
|
+
|
|
20
|
+
# Remote Tomcat server setting section
|
|
21
|
+
set :tomcat_user, 'tomcat7'
|
|
22
|
+
set :tomcat_user_group, 'tomcat7'
|
|
23
|
+
set :tomcat_port, '8080'
|
|
24
|
+
set :tomcat_cmd, '/etc/init.d/tomcat7'
|
|
25
|
+
set :use_tomcat_user_cmd, false
|
|
26
|
+
set :tomcat_war_file, '/var/app/war/test-web.war'
|
|
27
|
+
set :tomcat_context_path, '/test-web'
|
|
28
|
+
set :tomcat_context_file, '/var/lib/tomcat7/conf/Catalina/localhost/test-web.xml'
|
|
29
|
+
set :tomcat_work_dir, '/var/lib/tomcat7/work/Catalina/localhost/test-web'
|
|
30
|
+
|
|
31
|
+
# Deploy setting section
|
|
32
|
+
set :local_war_file, '/tmp/test-web.war'
|
|
33
|
+
set :context_template_file, File.expand_path('../../../templates/context.xml.erb', __FILE__).to_s
|
|
34
|
+
set :use_parallel, false
|
|
35
|
+
set :use_context_update, false
|
|
36
|
+
|
|
37
|
+
capistrano = Capistrano::Application.new
|
|
38
|
+
require 'capitomcat'
|
|
39
|
+
capistrano.invoke('capitomcat:deploy')
|
|
40
|
+
|
|
41
|
+
capistrano = Capistrano::Application.new
|
|
42
|
+
capistrano.add_import('../lib/native/tasks/tomcat_webapp.cap')
|
|
43
|
+
capistrano.load_imports
|
|
44
|
+
capistrano.invoke('tomcat:deploy')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.do_customized_cap
|
|
48
|
+
|
|
49
|
+
set :stage, :dev
|
|
50
|
+
|
|
51
|
+
set :format, :pretty
|
|
52
|
+
set :log_level, :info
|
|
53
|
+
set :pty, true
|
|
54
|
+
set :use_sudo, true
|
|
55
|
+
|
|
56
|
+
# Server definition section
|
|
57
|
+
role :app, %w{deploy@dev01 deploy@dev02}
|
|
58
|
+
|
|
59
|
+
# Remote Tomcat server setting section
|
|
60
|
+
set :tomcat_user, 'tomcat7'
|
|
61
|
+
set :tomcat_user_group, 'tomcat7'
|
|
62
|
+
set :tomcat_port, '8080'
|
|
63
|
+
set :tomcat_cmd, '/etc/init.d/tomcat7'
|
|
64
|
+
set :use_tomcat_user_cmd, false
|
|
65
|
+
set :tomcat_war_file, '/var/app/war/test-web.war'
|
|
66
|
+
set :tomcat_context_path, '/test-web'
|
|
67
|
+
set :tomcat_context_file, '/var/lib/tomcat7/conf/Catalina/localhost/test-web.xml'
|
|
68
|
+
set :tomcat_work_dir, '/var/lib/tomcat7/work/Catalina/localhost/test-web'
|
|
69
|
+
|
|
70
|
+
# Deploy setting section
|
|
71
|
+
set :local_war_file, '/tmp/test-web.war'
|
|
72
|
+
set :context_template_file, File.expand_path('../../../templates/context.xml.erb', __FILE__).to_s
|
|
73
|
+
set :use_parallel, false
|
|
74
|
+
|
|
75
|
+
capistrano = Capistrano::Application.new
|
|
76
|
+
capistrano.add_import('../lib/native/tasks/tomcat_webapp.cap')
|
|
77
|
+
capistrano.load_imports
|
|
78
|
+
capistrano.invoke('tomcat:deploy')
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Capitomcat
|
|
2
|
+
require 'capitomcat'
|
|
3
|
+
|
|
4
|
+
namespace :tomcat do
|
|
5
|
+
desc 'Tomcat WebApp Deployment with context.xml file updating'
|
|
6
|
+
task :deploy do
|
|
7
|
+
puts fetch(:context_template_file)
|
|
8
|
+
on roles(:app), in: get_parallelism, wait: 5 do |hosts|
|
|
9
|
+
info 'Upload WAR file'
|
|
10
|
+
upload_war_file
|
|
11
|
+
|
|
12
|
+
info 'Stop Tomcat'
|
|
13
|
+
stop_tomcat
|
|
14
|
+
|
|
15
|
+
info 'Update Context'
|
|
16
|
+
upload_context_file
|
|
17
|
+
|
|
18
|
+
info 'Clean Work directory'
|
|
19
|
+
cleanup_work_dir
|
|
20
|
+
|
|
21
|
+
info 'Start Tomcat'
|
|
22
|
+
start_tomcat
|
|
23
|
+
check_tomcat_started
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<Context path="<%= tomcat_context_path %>" docBase="<%= tomcat_war_file %>" />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Load DSL and Setup Up Stages
|
|
2
|
+
require 'capistrano/setup'
|
|
3
|
+
|
|
4
|
+
# Includes default deployment tasks
|
|
5
|
+
require 'capistrano/deploy'
|
|
6
|
+
|
|
7
|
+
# Includes tasks from other gems included in your Gemfile
|
|
8
|
+
#
|
|
9
|
+
# For documentation on these, see for example:
|
|
10
|
+
#
|
|
11
|
+
# https://github.com/capistrano/rvm
|
|
12
|
+
# https://github.com/capistrano/rbenv
|
|
13
|
+
# https://github.com/capistrano/chruby
|
|
14
|
+
# https://github.com/capistrano/bundler
|
|
15
|
+
# https://github.com/capistrano/rails/tree/master/assets
|
|
16
|
+
# https://github.com/capistrano/rails/tree/master/migrations
|
|
17
|
+
#
|
|
18
|
+
# require 'capistrano/rvm'
|
|
19
|
+
# require 'capistrano/rbenv'
|
|
20
|
+
# require 'capistrano/chruby'
|
|
21
|
+
# require 'capistrano/bundler'
|
|
22
|
+
# require 'capistrano/rails/assets'
|
|
23
|
+
# require 'capistrano/rails/migrations'
|
|
24
|
+
|
|
25
|
+
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
|
|
26
|
+
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Example Recipe for multi stage tomcat web-app deployment
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
set :stage, :dev
|
|
2
|
+
|
|
3
|
+
# Simple Role Syntax
|
|
4
|
+
# ==================
|
|
5
|
+
# Supports bulk-adding hosts to roles, the primary
|
|
6
|
+
# server in each group is considered to be the first
|
|
7
|
+
# unless any hosts have the primary property set.
|
|
8
|
+
role :app, %w{deploy@dev01 deploy@dev02}
|
|
9
|
+
|
|
10
|
+
# Extended Server Syntax
|
|
11
|
+
# ======================
|
|
12
|
+
# This can be used to drop a more detailed server
|
|
13
|
+
# definition into the server list. The second argument
|
|
14
|
+
# something that quacks like a hash can be used to set
|
|
15
|
+
# extended properties on the server.
|
|
16
|
+
|
|
17
|
+
# you can set custom ssh options
|
|
18
|
+
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
|
|
19
|
+
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
|
|
20
|
+
# set it globally
|
|
21
|
+
# set :ssh_options, {
|
|
22
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
|
23
|
+
# forward_agent: false,
|
|
24
|
+
# auth_methods: %w(password)
|
|
25
|
+
# }
|
|
26
|
+
# and/or per server
|
|
27
|
+
# server 'example.com',
|
|
28
|
+
# user: 'user_name',
|
|
29
|
+
# roles: %w{web app},
|
|
30
|
+
# ssh_options: {
|
|
31
|
+
# user: 'user_name', # overrides user setting above
|
|
32
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
|
33
|
+
# forward_agent: false,
|
|
34
|
+
# auth_methods: %w(publickey password)
|
|
35
|
+
# # password: 'please use keys'
|
|
36
|
+
# }
|
|
37
|
+
# setting per server overrides global ssh_options
|
|
38
|
+
|
|
39
|
+
# fetch(:default_env).merge!(rails_env: :production)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
set :stage, :production
|
|
2
|
+
|
|
3
|
+
# Simple Role Syntax
|
|
4
|
+
# ==================
|
|
5
|
+
# Supports bulk-adding hosts to roles, the primary
|
|
6
|
+
# server in each group is considered to be the first
|
|
7
|
+
# unless any hosts have the primary property set.
|
|
8
|
+
role :app, %w{deploy@prod01 deploy@prod02}
|
|
9
|
+
|
|
10
|
+
# Extended Server Syntax
|
|
11
|
+
# ======================
|
|
12
|
+
# This can be used to drop a more detailed server
|
|
13
|
+
# definition into the server list. The second argument
|
|
14
|
+
# something that quacks like a hash can be used to set
|
|
15
|
+
# extended properties on the server.
|
|
16
|
+
|
|
17
|
+
# you can set custom ssh options
|
|
18
|
+
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
|
|
19
|
+
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
|
|
20
|
+
# set it globally
|
|
21
|
+
# set :ssh_options, {
|
|
22
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
|
23
|
+
# forward_agent: false,
|
|
24
|
+
# auth_methods: %w(password)
|
|
25
|
+
# }
|
|
26
|
+
# and/or per server
|
|
27
|
+
# server 'example.com',
|
|
28
|
+
# user: 'user_name',
|
|
29
|
+
# roles: %w{web app},
|
|
30
|
+
# ssh_options: {
|
|
31
|
+
# user: 'user_name', # overrides user setting above
|
|
32
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
|
33
|
+
# forward_agent: false,
|
|
34
|
+
# auth_methods: %w(publickey password)
|
|
35
|
+
# # password: 'please use keys'
|
|
36
|
+
# }
|
|
37
|
+
# setting per server overrides global ssh_options
|
|
38
|
+
|
|
39
|
+
# fetch(:default_env).merge!(rails_env: :production)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
set :stage, :staging
|
|
2
|
+
|
|
3
|
+
# Simple Role Syntax
|
|
4
|
+
# ==================
|
|
5
|
+
# Supports bulk-adding hosts to roles, the primary
|
|
6
|
+
# server in each group is considered to be the first
|
|
7
|
+
# unless any hosts have the primary property set.
|
|
8
|
+
role :app, %w{deploy@stg01 deploy@stg02}
|
|
9
|
+
|
|
10
|
+
# Extended Server Syntax
|
|
11
|
+
# ======================
|
|
12
|
+
# This can be used to drop a more detailed server
|
|
13
|
+
# definition into the server list. The second argument
|
|
14
|
+
# something that quacks like a hash can be used to set
|
|
15
|
+
# extended properties on the server.
|
|
16
|
+
|
|
17
|
+
# you can set custom ssh options
|
|
18
|
+
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
|
|
19
|
+
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
|
|
20
|
+
# set it globally
|
|
21
|
+
# set :ssh_options, {
|
|
22
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
|
23
|
+
# forward_agent: false,
|
|
24
|
+
# auth_methods: %w(password)
|
|
25
|
+
# }
|
|
26
|
+
# and/or per server
|
|
27
|
+
# server 'example.com',
|
|
28
|
+
# user: 'user_name',
|
|
29
|
+
# roles: %w{web app},
|
|
30
|
+
# ssh_options: {
|
|
31
|
+
# user: 'user_name', # overrides user setting above
|
|
32
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
|
33
|
+
# forward_agent: false,
|
|
34
|
+
# auth_methods: %w(publickey password)
|
|
35
|
+
# # password: 'please use keys'
|
|
36
|
+
# }
|
|
37
|
+
# setting per server overrides global ssh_options
|
|
38
|
+
|
|
39
|
+
# fetch(:default_env).merge!(rails_env: :staging)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
set :application, 'my_app_name'
|
|
2
|
+
set :repo_url, 'git@example.com:me/my_repo.git'
|
|
3
|
+
|
|
4
|
+
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
|
|
5
|
+
|
|
6
|
+
# set :deploy_to, '/var/www/my_app'
|
|
7
|
+
# set :scm, :git
|
|
8
|
+
|
|
9
|
+
# set :format, :pretty
|
|
10
|
+
# set :log_level, :debug
|
|
11
|
+
# set :pty, true
|
|
12
|
+
|
|
13
|
+
# set :linked_files, %w{config/database.yml}
|
|
14
|
+
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
|
|
15
|
+
|
|
16
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
|
17
|
+
# set :keep_releases, 5
|
|
18
|
+
|
|
19
|
+
namespace :deploy do
|
|
20
|
+
|
|
21
|
+
desc 'Restart application'
|
|
22
|
+
task :restart do
|
|
23
|
+
on roles(:app), in: :sequence, wait: 5 do
|
|
24
|
+
# Your restart mechanism here, for example:
|
|
25
|
+
# execute :touch, release_path.join('tmp/restart.txt')
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
after :restart, :clear_cache do
|
|
30
|
+
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
|
31
|
+
# Here we can do anything such as:
|
|
32
|
+
# within release_path do
|
|
33
|
+
# execute :rake, 'cache:clear'
|
|
34
|
+
# end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
after :finishing, 'deploy:cleanup'
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Capitomcat
|
|
2
|
+
require 'capitomcat'
|
|
3
|
+
|
|
4
|
+
set :format, :pretty
|
|
5
|
+
set :log_level, :info
|
|
6
|
+
set :pty, true
|
|
7
|
+
set :use_sudo, true
|
|
8
|
+
|
|
9
|
+
# Remote Tomcat server setting section
|
|
10
|
+
set :tomcat_user, 'tomcat7'
|
|
11
|
+
set :tomcat_user_group, 'tomcat7'
|
|
12
|
+
set :tomcat_port, '8080'
|
|
13
|
+
set :tomcat_cmd, '/etc/init.d/tomcat7'
|
|
14
|
+
set :use_tomcat_user_cmd, false
|
|
15
|
+
set :tomcat_war_file, '/var/app/war/test-web.war'
|
|
16
|
+
set :tomcat_context_path, '/test-web'
|
|
17
|
+
set :tomcat_context_file, '/var/lib/tomcat7/conf/Catalina/localhost/test-web.xml'
|
|
18
|
+
set :tomcat_work_dir, '/var/lib/tomcat7/work/Catalina/localhost/test-web'
|
|
19
|
+
|
|
20
|
+
# Deploy setting section
|
|
21
|
+
set :local_war_file, '/tmp/test-web.war'
|
|
22
|
+
set :context_template_file, File.expand_path('../../../../templates/context.xml.erb', __FILE__).to_s
|
|
23
|
+
set :use_parallel, true
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
namespace :my_tomcat_recipe do
|
|
27
|
+
desc <<-DESC
|
|
28
|
+
Also, you can make your own tomcat recipe with method of Capitomcat
|
|
29
|
+
DESC
|
|
30
|
+
task :my_task do
|
|
31
|
+
on roles(:app), in: get_parallelism, wait: 5 do |hosts|
|
|
32
|
+
info 'Upload WAR file'
|
|
33
|
+
upload_war_file
|
|
34
|
+
|
|
35
|
+
info 'Stop Tomcat'
|
|
36
|
+
stop_tomcat
|
|
37
|
+
|
|
38
|
+
info 'Update Context'
|
|
39
|
+
upload_context_file
|
|
40
|
+
|
|
41
|
+
info 'Clean Work directory'
|
|
42
|
+
cleanup_work_dir
|
|
43
|
+
|
|
44
|
+
info 'Start Tomcat'
|
|
45
|
+
start_tomcat
|
|
46
|
+
check_tomcat_started
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<Context path="<%= tomcat_context_path %>" docBase="<%= tomcat_war_file %>" />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Load DSL and Setup Up Stages
|
|
2
|
+
require 'capistrano/setup'
|
|
3
|
+
|
|
4
|
+
# Includes default deployment tasks
|
|
5
|
+
require 'capistrano/deploy'
|
|
6
|
+
|
|
7
|
+
# Includes tasks from other gems included in your Gemfile
|
|
8
|
+
#
|
|
9
|
+
# For documentation on these, see for example:
|
|
10
|
+
#
|
|
11
|
+
# https://github.com/capistrano/rvm
|
|
12
|
+
# https://github.com/capistrano/rbenv
|
|
13
|
+
# https://github.com/capistrano/chruby
|
|
14
|
+
# https://github.com/capistrano/bundler
|
|
15
|
+
# https://github.com/capistrano/rails/tree/master/assets
|
|
16
|
+
# https://github.com/capistrano/rails/tree/master/migrations
|
|
17
|
+
#
|
|
18
|
+
# require 'capistrano/rvm'
|
|
19
|
+
# require 'capistrano/rbenv'
|
|
20
|
+
# require 'capistrano/chruby'
|
|
21
|
+
# require 'capistrano/bundler'
|
|
22
|
+
# require 'capistrano/rails/assets'
|
|
23
|
+
# require 'capistrano/rails/migrations'
|
|
24
|
+
|
|
25
|
+
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
|
|
26
|
+
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Example Recipe for multi stage tomcat web-app deployment
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
set :stage, :dev
|
|
2
|
+
|
|
3
|
+
# Simple Role Syntax
|
|
4
|
+
# ==================
|
|
5
|
+
# Supports bulk-adding hosts to roles, the primary
|
|
6
|
+
# server in each group is considered to be the first
|
|
7
|
+
# unless any hosts have the primary property set.
|
|
8
|
+
role :app, %w{deploy@dev01 deploy@dev02}
|
|
9
|
+
|
|
10
|
+
# Extended Server Syntax
|
|
11
|
+
# ======================
|
|
12
|
+
# This can be used to drop a more detailed server
|
|
13
|
+
# definition into the server list. The second argument
|
|
14
|
+
# something that quacks like a hash can be used to set
|
|
15
|
+
# extended properties on the server.
|
|
16
|
+
|
|
17
|
+
# you can set custom ssh options
|
|
18
|
+
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
|
|
19
|
+
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
|
|
20
|
+
# set it globally
|
|
21
|
+
# set :ssh_options, {
|
|
22
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
|
23
|
+
# forward_agent: false,
|
|
24
|
+
# auth_methods: %w(password)
|
|
25
|
+
# }
|
|
26
|
+
# and/or per server
|
|
27
|
+
# server 'example.com',
|
|
28
|
+
# user: 'user_name',
|
|
29
|
+
# roles: %w{web app},
|
|
30
|
+
# ssh_options: {
|
|
31
|
+
# user: 'user_name', # overrides user setting above
|
|
32
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
|
33
|
+
# forward_agent: false,
|
|
34
|
+
# auth_methods: %w(publickey password)
|
|
35
|
+
# # password: 'please use keys'
|
|
36
|
+
# }
|
|
37
|
+
# setting per server overrides global ssh_options
|
|
38
|
+
|
|
39
|
+
# fetch(:default_env).merge!(rails_env: :production)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
set :stage, :production
|
|
2
|
+
|
|
3
|
+
# Simple Role Syntax
|
|
4
|
+
# ==================
|
|
5
|
+
# Supports bulk-adding hosts to roles, the primary
|
|
6
|
+
# server in each group is considered to be the first
|
|
7
|
+
# unless any hosts have the primary property set.
|
|
8
|
+
role :app, %w{deploy@prod01 deploy@prod02}
|
|
9
|
+
|
|
10
|
+
# Extended Server Syntax
|
|
11
|
+
# ======================
|
|
12
|
+
# This can be used to drop a more detailed server
|
|
13
|
+
# definition into the server list. The second argument
|
|
14
|
+
# something that quacks like a hash can be used to set
|
|
15
|
+
# extended properties on the server.
|
|
16
|
+
|
|
17
|
+
# you can set custom ssh options
|
|
18
|
+
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
|
|
19
|
+
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
|
|
20
|
+
# set it globally
|
|
21
|
+
# set :ssh_options, {
|
|
22
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
|
23
|
+
# forward_agent: false,
|
|
24
|
+
# auth_methods: %w(password)
|
|
25
|
+
# }
|
|
26
|
+
# and/or per server
|
|
27
|
+
# server 'example.com',
|
|
28
|
+
# user: 'user_name',
|
|
29
|
+
# roles: %w{web app},
|
|
30
|
+
# ssh_options: {
|
|
31
|
+
# user: 'user_name', # overrides user setting above
|
|
32
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
|
33
|
+
# forward_agent: false,
|
|
34
|
+
# auth_methods: %w(publickey password)
|
|
35
|
+
# # password: 'please use keys'
|
|
36
|
+
# }
|
|
37
|
+
# setting per server overrides global ssh_options
|
|
38
|
+
|
|
39
|
+
# fetch(:default_env).merge!(rails_env: :production)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
set :stage, :staging
|
|
2
|
+
|
|
3
|
+
# Simple Role Syntax
|
|
4
|
+
# ==================
|
|
5
|
+
# Supports bulk-adding hosts to roles, the primary
|
|
6
|
+
# server in each group is considered to be the first
|
|
7
|
+
# unless any hosts have the primary property set.
|
|
8
|
+
role :app, %w{deploy@stg01 deploy@stg02}
|
|
9
|
+
|
|
10
|
+
# Extended Server Syntax
|
|
11
|
+
# ======================
|
|
12
|
+
# This can be used to drop a more detailed server
|
|
13
|
+
# definition into the server list. The second argument
|
|
14
|
+
# something that quacks like a hash can be used to set
|
|
15
|
+
# extended properties on the server.
|
|
16
|
+
|
|
17
|
+
# you can set custom ssh options
|
|
18
|
+
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
|
|
19
|
+
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
|
|
20
|
+
# set it globally
|
|
21
|
+
# set :ssh_options, {
|
|
22
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
|
23
|
+
# forward_agent: false,
|
|
24
|
+
# auth_methods: %w(password)
|
|
25
|
+
# }
|
|
26
|
+
# and/or per server
|
|
27
|
+
# server 'example.com',
|
|
28
|
+
# user: 'user_name',
|
|
29
|
+
# roles: %w{web app},
|
|
30
|
+
# ssh_options: {
|
|
31
|
+
# user: 'user_name', # overrides user setting above
|
|
32
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
|
33
|
+
# forward_agent: false,
|
|
34
|
+
# auth_methods: %w(publickey password)
|
|
35
|
+
# # password: 'please use keys'
|
|
36
|
+
# }
|
|
37
|
+
# setting per server overrides global ssh_options
|
|
38
|
+
|
|
39
|
+
# fetch(:default_env).merge!(rails_env: :staging)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
set :application, 'my_app_name'
|
|
2
|
+
set :repo_url, 'git@example.com:me/my_repo.git'
|
|
3
|
+
|
|
4
|
+
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
|
|
5
|
+
|
|
6
|
+
# set :deploy_to, '/var/www/my_app'
|
|
7
|
+
# set :scm, :git
|
|
8
|
+
|
|
9
|
+
# set :format, :pretty
|
|
10
|
+
# set :log_level, :debug
|
|
11
|
+
# set :pty, true
|
|
12
|
+
|
|
13
|
+
# set :linked_files, %w{config/database.yml}
|
|
14
|
+
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
|
|
15
|
+
|
|
16
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
|
17
|
+
# set :keep_releases, 5
|
|
18
|
+
|
|
19
|
+
namespace :deploy do
|
|
20
|
+
|
|
21
|
+
desc 'Restart application'
|
|
22
|
+
task :restart do
|
|
23
|
+
on roles(:app), in: :sequence, wait: 5 do
|
|
24
|
+
# Your restart mechanism here, for example:
|
|
25
|
+
# execute :touch, release_path.join('tmp/restart.txt')
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
after :restart, :clear_cache do
|
|
30
|
+
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
|
31
|
+
# Here we can do anything such as:
|
|
32
|
+
# within release_path do
|
|
33
|
+
# execute :rake, 'cache:clear'
|
|
34
|
+
# end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
after :finishing, 'deploy:cleanup'
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Capitomcat
|
|
2
|
+
require 'capitomcat'
|
|
3
|
+
|
|
4
|
+
set :format, :pretty
|
|
5
|
+
set :log_level, :info
|
|
6
|
+
set :pty, true
|
|
7
|
+
set :use_sudo, true
|
|
8
|
+
|
|
9
|
+
# Remote Tomcat server setting section
|
|
10
|
+
set :tomcat_user, 'tomcat7'
|
|
11
|
+
set :tomcat_user_group, 'tomcat7'
|
|
12
|
+
set :tomcat_port, '8080'
|
|
13
|
+
set :tomcat_cmd, '/etc/init.d/tomcat7'
|
|
14
|
+
set :use_tomcat_user_cmd, false
|
|
15
|
+
set :tomcat_war_file, '/var/app/war/test-web.war'
|
|
16
|
+
set :tomcat_context_path, '/test-web'
|
|
17
|
+
set :tomcat_context_file, '/var/lib/tomcat7/conf/Catalina/localhost/test-web.xml'
|
|
18
|
+
set :tomcat_work_dir, '/var/lib/tomcat7/work/Catalina/localhost/test-web'
|
|
19
|
+
|
|
20
|
+
# Deploy setting section
|
|
21
|
+
set :local_war_file, '/tmp/test-web.war'
|
|
22
|
+
set :context_template_file, File.expand_path('../../../../templates/context.xml.erb', __FILE__).to_s
|
|
23
|
+
set :use_parallel, true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<Context path="<%= tomcat_context_path %>" docBase="<%= tomcat_war_file %>" />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Load DSL and Setup Up Stages
|
|
2
|
+
require 'capistrano/setup'
|
|
3
|
+
|
|
4
|
+
# Includes default deployment tasks
|
|
5
|
+
require 'capistrano/deploy'
|
|
6
|
+
|
|
7
|
+
# Includes tasks from other gems included in your Gemfile
|
|
8
|
+
#
|
|
9
|
+
# For documentation on these, see for example:
|
|
10
|
+
#
|
|
11
|
+
# https://github.com/capistrano/rvm
|
|
12
|
+
# https://github.com/capistrano/rbenv
|
|
13
|
+
# https://github.com/capistrano/chruby
|
|
14
|
+
# https://github.com/capistrano/bundler
|
|
15
|
+
# https://github.com/capistrano/rails/tree/master/assets
|
|
16
|
+
# https://github.com/capistrano/rails/tree/master/migrations
|
|
17
|
+
#
|
|
18
|
+
# require 'capistrano/rvm'
|
|
19
|
+
# require 'capistrano/rbenv'
|
|
20
|
+
# require 'capistrano/chruby'
|
|
21
|
+
# require 'capistrano/bundler'
|
|
22
|
+
# require 'capistrano/rails/assets'
|
|
23
|
+
# require 'capistrano/rails/migrations'
|
|
24
|
+
|
|
25
|
+
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
|
|
26
|
+
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Example Recipe for single stage tomcat web-app deployment
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Capitomcat
|
|
2
|
+
require 'capitomcat'
|
|
3
|
+
|
|
4
|
+
set :stage, :dev
|
|
5
|
+
|
|
6
|
+
set :format, :pretty
|
|
7
|
+
set :log_level, :info
|
|
8
|
+
set :pty, true
|
|
9
|
+
set :use_sudo, true
|
|
10
|
+
|
|
11
|
+
# Server definition section
|
|
12
|
+
role :app, %w{deploy@dev01 deploy@dev02}
|
|
13
|
+
|
|
14
|
+
# Remote Tomcat server setting section
|
|
15
|
+
set :tomcat_user, 'tomcat7'
|
|
16
|
+
set :tomcat_user_group, 'tomcat7'
|
|
17
|
+
set :tomcat_port, '8080'
|
|
18
|
+
set :tomcat_cmd, '/etc/init.d/tomcat7'
|
|
19
|
+
set :use_tomcat_user_cmd, false
|
|
20
|
+
set :tomcat_war_file, '/var/app/war/test-web.war'
|
|
21
|
+
set :tomcat_context_path, '/test-web'
|
|
22
|
+
set :tomcat_context_file, '/var/lib/tomcat7/conf/Catalina/localhost/test-web.xml'
|
|
23
|
+
set :tomcat_work_dir, '/var/lib/tomcat7/work/Catalina/localhost/test-web'
|
|
24
|
+
|
|
25
|
+
# Deploy setting section
|
|
26
|
+
set :local_war_file, '/tmp/test-web.war'
|
|
27
|
+
set :context_template_file, File.expand_path('../../../../templates/context.xml.erb', __FILE__).to_s
|
|
28
|
+
set :use_parallel, true
|
|
29
|
+
set :use_context_update, false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<Context path="<%= tomcat_context_path %>" docBase="<%= tomcat_war_file %>" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
load File.expand_path('../tasks/deploy.cap', __FILE__)
|