uhl-cap-recipes 0.1.10 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b962d0fab79181a8f289c3a3357f59365ea1f24b
4
+ data.tar.gz: 4116b71959a6d2e8ffe006168e1ba58bc202e68d
5
+ SHA512:
6
+ metadata.gz: d3d9841a4dc8bc6e2fa86ae53551a28f3677a9a2043fecb3f1e4c27368ce412bb9ea09136740dc1e631fe116aa2fa20d9d560282db60ae6656c4e3196f4d62a9
7
+ data.tar.gz: ed0caaad9759f8fd5b10c902d1dd03112235d2611f1e228c041d37c85e85b928004dbe2a11de34fc8a89bf46ee406e14084aed350f3fe102af92f6a815e3db3f
data/Rakefile CHANGED
@@ -24,9 +24,9 @@ begin
24
24
  s.authors = ["crazycode"]
25
25
  s.rubyforge_project = 'uhl-cap-recipes'
26
26
 
27
- s.add_dependency "capistrano"
28
- s.add_dependency "json"
29
- s.add_dependency "addressable"
27
+ s.add_dependency "capistrano", '~> 0'
28
+ s.add_dependency "json", '~> 0'
29
+ s.add_dependency "addressable", '~> 0'
30
30
  end
31
31
  Jeweler::GemcutterTasks.new
32
32
  rescue LoadError
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 1
3
+ :minor: 2
4
4
  :patch: 10
5
5
  :build:
data/jenkins-capfile ADDED
@@ -0,0 +1,24 @@
1
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2
+ Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
3
+
4
+ set :application, "demo"
5
+
6
+ set :user, "deploy"
7
+ set :use_sudo, true
8
+
9
+ # set :gateway, 'deploy@119.15.137.30:10222'
10
+
11
+ ssh_options[:paranoid] = false
12
+ default_run_options[:pty] = true
13
+ default_run_options[:shell] = '/bin/bash'
14
+
15
+ # =============================================================================
16
+ # RECIPE INCLUDES
17
+ # =============================================================================
18
+
19
+ require 'rubygems'
20
+ # for development
21
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
22
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
23
+
24
+ require 'cap_recipes/tasks/springboot'
@@ -2,7 +2,7 @@
2
2
  Capistrano::Configuration.instance(true).load do |configuration|
3
3
  set :use_sudo, true
4
4
 
5
- _cset :deploy_to_parent, "/app"
5
+ _cset :deploy_to_parent, "/opt"
6
6
  _cset :branch, "master"
7
7
 
8
8
  default_run_options[:pty] = true
@@ -201,7 +201,7 @@ Capistrano::Configuration.instance(true).load do |configuration|
201
201
  [
202
202
  "if [ ! -e #{reeb_config_dir} ]",
203
203
  "then sudo mkdir -p #{reeb_config_dir}",
204
- "sudo chown #{user} #{deploy_to}",
204
+ "sudo chown #{user} #{reeb_config_dir}",
205
205
  "cd #{reeb_config_dir}",
206
206
  "git clone #{reeb_config_repository} .",
207
207
  "fi",
@@ -0,0 +1,252 @@
1
+ # -*- coding: utf-8 -*-
2
+ # cap -f /etc/jenkins-capfile -s deploy_to_parent=/opt/ngfsn -s application=switcher -s service_name=spring-switcher -s servers=10.65.216.18,10.65.216.19 -s repository=git@gitlab.vfinance.cn:build/switcher.git springboot:redeploy
3
+ # cap -f /etc/jenkins-capfile -s deploy_to_parent=/opt/ngfsn -s application=exchange -s service_name=spring-exchange -s servers=10.65.216.18,10.65.216.19 -s repository=git@gitlab.vfinance.cn:build/exchange.git springboot:redeploy
4
+ # cap -f /etc/jenkins-capfile -s deploy_to_parent=/opt/ngfsn -s application=investor -s service_name=spring-investor -s servers=10.65.216.18,10.65.216.19 -s repository=git@gitlab.vfinance.cn:build/investor.git springboot:redeploy
5
+ # cap -f /etc/jenkins-capfile -s deploy_to_parent=/opt/ngfsn -s application=issuer -s service_name=spring-issuer -s servers=10.65.216.18,10.65.216.19 -s repository=git@gitlab.vfinance.cn:build/issuer.git springboot:redeploy
6
+
7
+ Capistrano::Configuration.instance(true).load do |configuration|
8
+ set :use_sudo, true
9
+
10
+ _cset :deploy_to_parent, "/opt"
11
+ _cset :branch, "master"
12
+
13
+ default_run_options[:pty] = true
14
+
15
+ # this is capistrano's default location.
16
+ # depending on the permissions of the server
17
+ # you may need to create it and chown it over
18
+ # to :user (e.g. chown -R robotuser:robotuser /u)
19
+ set :deploy_to do
20
+ "#{deploy_to_parent}/deploy"
21
+ end
22
+
23
+ set :deploy_to_gitrepo do
24
+ "#{deploy_to}/#{application}"
25
+ end
26
+
27
+ set :local_base_dir do
28
+ "#{`pwd`}".strip
29
+ end
30
+
31
+ set :service_name do
32
+ "#{application}"
33
+ end
34
+
35
+ set :service_check_name do
36
+ "#{application}"
37
+ end
38
+
39
+ _cset :_config, Array.new
40
+ _cset :build_name, "ROOT"
41
+ _cset :build_path, "not_set_build_path"
42
+
43
+ _cset :app_config_dir, "/app/config"
44
+ _cset :app_config_repository, "git@gitlab.vfinance.cn:configuration/matrix-demo.git"
45
+
46
+ _cset :servers, ""
47
+
48
+ set :local_git_dir do
49
+ "/app/tmp/localgit_#{application}"
50
+ end
51
+
52
+ set :local_gitrepo do
53
+ "#{local_git_dir}/#{application}"
54
+ end
55
+
56
+ role :app, :primary => true do
57
+ if servers.empty?
58
+ "1.1.1.1"
59
+ else
60
+ servers.split(/[,\s]+/)
61
+ end
62
+ end
63
+
64
+ namespace :springboot do
65
+
66
+ desc "start service"
67
+ task :start do
68
+ sudo "/etc/init.d/#{service_name} start"
69
+ # sleep 1
70
+ # api_status = nil
71
+ # until api_status
72
+ # api_status = capture("echo `netstat -tln | grep 8080`")
73
+ # sleep 60
74
+ # end
75
+ # puts "API Started successfully."
76
+ end
77
+
78
+ desc "stop service"
79
+ task :stop do
80
+ sudo "/etc/init.d/#{service_name} stop"
81
+ end
82
+
83
+ desc "stop and start service"
84
+ task :restart do
85
+ springboot.stop
86
+ springboot.start
87
+ end
88
+
89
+ desc "deploy, then stop and start service"
90
+ task :redeploy do
91
+ springboot.deploy
92
+ springboot.stop
93
+ springboot.start
94
+ end
95
+
96
+ desc "setup remote and locate application dir"
97
+ task :setup do
98
+ springboot.setup_remote
99
+ springboot.setup_local
100
+ end
101
+
102
+ desc "setup remote application dir"
103
+ task :setup_remote do
104
+ run clone_repository_command()
105
+ end
106
+
107
+ desc "setup locate application dir"
108
+ task :setup_local do
109
+ system clone_repository_local_command()
110
+ end
111
+
112
+ desc "just pull current build version, doesn't add tag."
113
+ task :pull do
114
+ springboot.setup_local
115
+
116
+ system "cd #{local_gitrepo}; git checkout #{branch}; git fetch; git rebase origin/#{branch};"
117
+
118
+ unless play_name.empty?
119
+ puts "name=#{play_name}, war=#{play_path}"
120
+ system update_repository_local_command(play_name, play_path)
121
+ else
122
+ if war_config.nil? or war_config.size == 0
123
+ raise 'NO war_config'
124
+ end
125
+ war_config.each do |config|
126
+ puts "name=#{config[:name]}, war=#{config[:war]}"
127
+ system update_repository_local_command(config[:name], config[:war])
128
+ end
129
+ end
130
+
131
+ build_msg = play_name.empty? ? "all" : play_name
132
+ system "cd #{local_gitrepo}; git add .; git commit -m 'build for #{build_msg}'"
133
+
134
+ # push tags and latest code
135
+ system "cd #{local_gitrepo}; git push origin #{branch}"
136
+ if $? != 0
137
+ raise "git push failed"
138
+ end
139
+
140
+ end
141
+
142
+ desc "tag build version. use -s tag=xxx to set tag's name"
143
+ task :tag do
144
+ springboot.setup_local
145
+ system "cd #{local_gitrepo}; git checkout #{branch}; git fetch; git rebase origin/#{branch};"
146
+
147
+ tag_name = configuration[:tag] || configuration[:build_version]
148
+ raise "NO tag. pls use -s tag=xxx set tag_name" if tag_name.nil?
149
+
150
+ system "cd #{local_gitrepo}; git tag #{tag_name};"
151
+
152
+ system "cd #{local_gitrepo}; git push origin #{branch} --tags"
153
+ if $? != 0
154
+ raise "git push --tags failed"
155
+ end
156
+ end
157
+
158
+ desc "deploy. use -s tag=xxx to set tag's name, if NOT set tag, pull the repository's last version."
159
+ task :deploy do
160
+ springboot.setup_remote
161
+ #run springboot.setup_or_update_reeb_config
162
+ tag_name = configuration[:tag] || configuration[:build_version]
163
+ unless tag_name.nil?
164
+ # raise "NO tag. pls use -s tag=xxx set tag_name"
165
+ run update_repository_remote_command(tag_name)
166
+ else
167
+ run pull_repository_remote_command(branch)
168
+ end
169
+ run record_git_reversion_command()
170
+ end
171
+
172
+ def self.clone_repository_local_command
173
+ [
174
+ "rm -Rf #{local_git_dir}",
175
+ "mkdir -p #{local_git_dir}",
176
+ "cd #{local_git_dir}",
177
+ "git clone #{repository} #{local_gitrepo}"
178
+ ].join("; ")
179
+ end
180
+
181
+
182
+ def self.update_repository_local_command(name, path)
183
+ unless path.start_with?('/')
184
+ play_path = "#{local_base_dir}/#{path}"
185
+ else
186
+ play_path = path
187
+ end
188
+ [
189
+ "cd #{local_gitrepo}",
190
+ "if [ -e #{local_gitrepo}/#{name} ]",
191
+ "then git rm -rf #{local_gitrepo}/#{name}",
192
+ "fi",
193
+ "mkdir -p #{local_gitrepo}/#{name}",
194
+ "cd #{local_gitrepo}/#{name}",
195
+ "cp #{play_path}/* . -r"
196
+ ].join("; ")
197
+ end
198
+
199
+ def self.setup_or_update_reeb_config
200
+ [
201
+ "if [ ! -e #{reeb_config_dir} ]",
202
+ "then mkdir -p #{reeb_config_dir}",
203
+ "chown #{user} #{reeb_config_dir}",
204
+ "cd #{reeb_config_dir}",
205
+ "git clone #{reeb_config_repository} .",
206
+ "fi",
207
+ "cd #{reeb_config_dir}",
208
+ "git pull"
209
+ ].join("; ")
210
+ end
211
+
212
+ def self.clone_repository_command
213
+ [
214
+ "if [ ! -e #{deploy_to_gitrepo} ]",
215
+ "then mkdir -p #{deploy_to}",
216
+ "chown #{user} #{deploy_to}",
217
+ "cd #{deploy_to}",
218
+ "git clone #{repository} #{deploy_to_gitrepo}",
219
+ "fi"
220
+ ].join("; ")
221
+ end
222
+
223
+ def self.update_repository_remote_command(tag_name)
224
+ [
225
+ # git reset --hard;git fetch;git reset --merge #{tag_name}
226
+ "cd #{deploy_to_gitrepo}",
227
+ "git reset --hard",
228
+ "git fetch",
229
+ "git reset --merge #{tag_name}",
230
+ ].join("; ")
231
+ end
232
+
233
+ def self.pull_repository_remote_command(branch)
234
+ [
235
+ # git reset --hard;git fetch;git reset --merge #{tag_name}
236
+ "cd #{deploy_to_gitrepo}",
237
+ "git reset --hard",
238
+ "git fetch",
239
+ "git rebase origin/#{branch}",
240
+ ].join("; ")
241
+ end
242
+
243
+ def self.record_git_reversion_command()
244
+ [
245
+ "cd #{deploy_to_gitrepo}",
246
+ "echo \"$(date +\"%Y-%m-%d %H:%M:%S\") $(git log --pretty -1 | awk '/^commit/{print $2}')\" >> #{deploy_to}/#{application}_reversion",
247
+ ].join("; ")
248
+ end
249
+
250
+ end
251
+
252
+ end
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: uhl-cap-recipes 0.2.10 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "uhl-cap-recipes"
8
- s.version = "0.1.10"
9
+ s.version = "0.2.10"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["crazycode"]
12
- s.date = "2012-12-12"
14
+ s.date = "2016-06-01"
13
15
  s.description = "capistrano recipes for my works"
14
16
  s.email = "crazycode@gmail.com"
15
17
  s.executables = ["cap-recipes"]
@@ -31,6 +33,7 @@ Gem::Specification.new do |s|
31
33
  "examples/advanced/deploy/experimental.rb",
32
34
  "examples/advanced/deploy/production.rb",
33
35
  "examples/simple/deploy.rb",
36
+ "jenkins-capfile",
34
37
  "lib/cap_recipes.rb",
35
38
  "lib/cap_recipes/tasks/gitdeploy.rb",
36
39
  "lib/cap_recipes/tasks/gitdeploy/setup.rb",
@@ -40,6 +43,7 @@ Gem::Specification.new do |s|
40
43
  "lib/cap_recipes/tasks/sdpdeploy/iis.rb",
41
44
  "lib/cap_recipes/tasks/sdpdeploy/sft.rb",
42
45
  "lib/cap_recipes/tasks/sdpdeploy/sfttask.rb",
46
+ "lib/cap_recipes/tasks/springboot.rb",
43
47
  "lib/cap_recipes/tasks/templates/hudson.erb",
44
48
  "lib/cap_recipes/tasks/templates/mongod.conf.erb",
45
49
  "lib/cap_recipes/tasks/templates/mongodb.init.erb",
@@ -60,27 +64,26 @@ Gem::Specification.new do |s|
60
64
  "uhl-cap-recipes.gemspec"
61
65
  ]
62
66
  s.homepage = "http://github.com/crazycode/uhl-cap-recipes"
63
- s.require_paths = ["lib"]
64
67
  s.rubyforge_project = "uhl-cap-recipes"
65
- s.rubygems_version = "1.8.24"
68
+ s.rubygems_version = "2.5.1"
66
69
  s.summary = "Battle-tested capistrano recipes for passenger, delayed_job, and more"
67
70
 
68
71
  if s.respond_to? :specification_version then
69
- s.specification_version = 3
72
+ s.specification_version = 4
70
73
 
71
74
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
- s.add_runtime_dependency(%q<capistrano>, [">= 0"])
73
- s.add_runtime_dependency(%q<json>, [">= 0"])
74
- s.add_runtime_dependency(%q<addressable>, [">= 0"])
75
+ s.add_runtime_dependency(%q<capistrano>, ["~> 0"])
76
+ s.add_runtime_dependency(%q<json>, ["~> 0"])
77
+ s.add_runtime_dependency(%q<addressable>, ["~> 0"])
75
78
  else
76
- s.add_dependency(%q<capistrano>, [">= 0"])
77
- s.add_dependency(%q<json>, [">= 0"])
78
- s.add_dependency(%q<addressable>, [">= 0"])
79
+ s.add_dependency(%q<capistrano>, ["~> 0"])
80
+ s.add_dependency(%q<json>, ["~> 0"])
81
+ s.add_dependency(%q<addressable>, ["~> 0"])
79
82
  end
80
83
  else
81
- s.add_dependency(%q<capistrano>, [">= 0"])
82
- s.add_dependency(%q<json>, [">= 0"])
83
- s.add_dependency(%q<addressable>, [">= 0"])
84
+ s.add_dependency(%q<capistrano>, ["~> 0"])
85
+ s.add_dependency(%q<json>, ["~> 0"])
86
+ s.add_dependency(%q<addressable>, ["~> 0"])
84
87
  end
85
88
  end
86
89
 
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uhl-cap-recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
5
- prerelease:
4
+ version: 0.2.10
6
5
  platform: ruby
7
6
  authors:
8
7
  - crazycode
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-12 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: capistrano
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: addressable
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: capistrano recipes for my works
@@ -81,6 +74,7 @@ files:
81
74
  - examples/advanced/deploy/experimental.rb
82
75
  - examples/advanced/deploy/production.rb
83
76
  - examples/simple/deploy.rb
77
+ - jenkins-capfile
84
78
  - lib/cap_recipes.rb
85
79
  - lib/cap_recipes/tasks/gitdeploy.rb
86
80
  - lib/cap_recipes/tasks/gitdeploy/setup.rb
@@ -90,6 +84,7 @@ files:
90
84
  - lib/cap_recipes/tasks/sdpdeploy/iis.rb
91
85
  - lib/cap_recipes/tasks/sdpdeploy/sft.rb
92
86
  - lib/cap_recipes/tasks/sdpdeploy/sfttask.rb
87
+ - lib/cap_recipes/tasks/springboot.rb
93
88
  - lib/cap_recipes/tasks/templates/hudson.erb
94
89
  - lib/cap_recipes/tasks/templates/mongod.conf.erb
95
90
  - lib/cap_recipes/tasks/templates/mongodb.init.erb
@@ -110,26 +105,25 @@ files:
110
105
  - uhl-cap-recipes.gemspec
111
106
  homepage: http://github.com/crazycode/uhl-cap-recipes
112
107
  licenses: []
108
+ metadata: {}
113
109
  post_install_message:
114
110
  rdoc_options: []
115
111
  require_paths:
116
112
  - lib
117
113
  required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
114
  requirements:
120
- - - ! '>='
115
+ - - ">="
121
116
  - !ruby/object:Gem::Version
122
117
  version: '0'
123
118
  required_rubygems_version: !ruby/object:Gem::Requirement
124
- none: false
125
119
  requirements:
126
- - - ! '>='
120
+ - - ">="
127
121
  - !ruby/object:Gem::Version
128
122
  version: '0'
129
123
  requirements: []
130
124
  rubyforge_project: uhl-cap-recipes
131
- rubygems_version: 1.8.24
125
+ rubygems_version: 2.5.1
132
126
  signing_key:
133
- specification_version: 3
127
+ specification_version: 4
134
128
  summary: Battle-tested capistrano recipes for passenger, delayed_job, and more
135
129
  test_files: []