osp-deploy 1.1.1 → 1.2.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.
- data/bin/osp-rails-deploy.rb +1 -1
- data/lib/osp_deploy/rails_deployer.rb +61 -68
- data/lib/osp_deploy/version.rb +1 -1
- metadata +2 -2
data/bin/osp-rails-deploy.rb
CHANGED
@@ -10,8 +10,8 @@ class OspDeploy::RailsDeployer
|
|
10
10
|
REQUIRED_OPTIONS = { :always => [:jobs, :server_uris, :tag_prefix],
|
11
11
|
:puma => [:remote_dest_file_dir],
|
12
12
|
:file => [:remote_dest_file_dir],
|
13
|
+
:war => [:remote_dest_file_dir, :war_file_name],
|
13
14
|
:torquebox => [:appl_name, :torquebox_home, :remote_dest_file_dir],
|
14
|
-
:precompile_assets => [:environment],
|
15
15
|
}
|
16
16
|
|
17
17
|
DEFAULT_EXCLUDES = ['coverage', 'nbproject', '.idea', 'tmp', 'log', '.git', '*~']
|
@@ -119,46 +119,42 @@ EOT
|
|
119
119
|
|
120
120
|
# Deploy this project to the remote-servers
|
121
121
|
def deploy
|
122
|
+
validate_config
|
122
123
|
gen_version_initializer
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
puma_deploy(server_uri) if @deployment_config['jobs'].include?(:puma)
|
130
|
-
precompile_assets_housekeeping if @deployment_config['jobs'].include?(:precompile_assets)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
threads.each{|t| t.join }
|
134
|
-
server_iterator do |server_uri|
|
135
|
-
execute_post_commands(server_uri)
|
124
|
+
|
125
|
+
do_before_local = @deployment_config['do_before_local']
|
126
|
+
do_cmds 'do_before_local', do_before_local
|
127
|
+
|
128
|
+
if @deployment_config['jobs'].include?(:war)
|
129
|
+
execute_cmd 'warble'
|
136
130
|
end
|
137
|
-
end
|
138
131
|
|
139
132
|
|
140
|
-
# Deploy this project and execute bundler
|
141
|
-
def deploy_and_bundle
|
142
|
-
gen_version_initializer
|
143
133
|
threads = nil
|
144
|
-
|
145
|
-
|
146
|
-
|
134
|
+
threads = server_iterator(:threads => true) do |server_uri|
|
135
|
+
do_before = @deployment_config['do_before']
|
136
|
+
do_cmds 'do_before_local', do_before, server_uri, false
|
137
|
+
|
138
|
+
if !(['file', 'torquebox', 'puma'] & @deployment_config['jobs']).empty?
|
147
139
|
sync_files_to_remote_server(server_uri)
|
148
|
-
bundler_actions_on_remote_server(server_uri)
|
149
|
-
torquebox_deploy(server_uri) if @deployment_config['jobs'].include?(:torquebox)
|
150
|
-
puma_deploy(server_uri) if @deployment_config['jobs'].include?(:puma)
|
151
|
-
precompile_assets_housekeeping if @deployment_config['jobs'].include?(:precompile_assets)
|
152
140
|
end
|
141
|
+
|
142
|
+
torquebox_deploy(server_uri) if @deployment_config['jobs'].include?(:torquebox)
|
143
|
+
puma_deploy(server_uri) if @deployment_config['jobs'].include?(:puma)
|
144
|
+
war_deploy(server_uri) if @deployment_config['jobs'].include?(:war)
|
145
|
+
|
146
|
+
do_after = @deployment_config['do_after'] || @deployment_config['post_commands']
|
147
|
+
do_cmds 'do_after', do_after, server_uri, false
|
153
148
|
end
|
154
149
|
threads.each{|t| t.join }
|
155
|
-
|
156
|
-
|
157
|
-
end
|
150
|
+
do_after_local = @deployment_config['do_after_local']
|
151
|
+
do_cmds 'do_after_local', do_after_local
|
158
152
|
end
|
159
153
|
|
160
154
|
|
161
155
|
|
156
|
+
|
157
|
+
|
162
158
|
# make git-log for last 20 commits in medium format into file last-changelog.txt
|
163
159
|
def make_last_changelog
|
164
160
|
logger.info "make_last_changelog"
|
@@ -213,19 +209,6 @@ EOT
|
|
213
209
|
|
214
210
|
|
215
211
|
|
216
|
-
def execute_post_commands server_uri
|
217
|
-
post_commands = @deployment_config['post_commands']
|
218
|
-
return if post_commands.nil?
|
219
|
-
raise "Option 'post_commands' expected an Array!" unless post_commands.is_a?(Array)
|
220
|
-
logger.info "Execute post-commands."
|
221
|
-
|
222
|
-
file_dir = @deployment_config['remote_dest_file_dir']
|
223
|
-
post_commands = ["cd #{file_dir}"] + post_commands if file_dir
|
224
|
-
|
225
|
-
cmd = "ssh #{server_uri} \"#{post_commands.join(' && ')}\""
|
226
|
-
execute_cmd(cmd)
|
227
|
-
end
|
228
|
-
|
229
212
|
|
230
213
|
|
231
214
|
# Rsync Project-Dir mit Remote-Server inkl. Rename der Config-Files
|
@@ -262,18 +245,6 @@ EOT
|
|
262
245
|
end
|
263
246
|
|
264
247
|
|
265
|
-
# Aufruf des Bundlers auf dem Zielsystem
|
266
|
-
def bundler_actions_on_remote_server server_uri
|
267
|
-
file_dir = @deployment_config['remote_dest_file_dir']
|
268
|
-
bundler_cmd = @deployment_config['bundler_cmd'] || BUNDLER_DEFAULT_CMD
|
269
|
-
logger.info "Execute '#{bundler_cmd}' on #{server_uri}:#{file_dir}"
|
270
|
-
runtime = Benchmark.realtime do
|
271
|
-
bout = @options[:verbose] ? nil : '> /dev/null'
|
272
|
-
cmd = "ssh #{server_uri} \"cd #{file_dir} && #{bundler_cmd}\" #{bout}"
|
273
|
-
execute_cmd cmd
|
274
|
-
end
|
275
|
-
logger.info "Execute bundler finished in #{runtime.round}s"
|
276
|
-
end
|
277
248
|
|
278
249
|
|
279
250
|
|
@@ -337,6 +308,19 @@ EOS
|
|
337
308
|
end
|
338
309
|
|
339
310
|
|
311
|
+
def war_deploy server_uri
|
312
|
+
war_file_src = "#{File.basename(Dir.getwd)}.war"
|
313
|
+
war_file_dest = File.join(@deployment_config['remote_dest_file_dir'], @deployment_config['war_file_name'])
|
314
|
+
if server_uri.start_with?('.') || server_uri.start_with?('/') || server_uri.start_with?('file:')
|
315
|
+
# local uri
|
316
|
+
dest = File.join server_uri, war_file_dest
|
317
|
+
else
|
318
|
+
dest = "#{server_uri}:#{war_file_dest}"
|
319
|
+
end
|
320
|
+
execute_cmd "scp #{war_file_src} #{dest}"
|
321
|
+
end
|
322
|
+
|
323
|
+
|
340
324
|
|
341
325
|
# read current branch
|
342
326
|
def parse_git_branch
|
@@ -346,7 +330,7 @@ EOS
|
|
346
330
|
end
|
347
331
|
|
348
332
|
|
349
|
-
# Überprüfen ob es Änderungen im
|
333
|
+
# Überprüfen ob es Änderungen im File-System gibt, die noch nicht in GIT eingecheckt wurden
|
350
334
|
def git_check
|
351
335
|
if @options[:no_git_check]
|
352
336
|
logger.warn "Skip GIT check !!! "
|
@@ -360,27 +344,36 @@ EOS
|
|
360
344
|
end
|
361
345
|
|
362
346
|
|
363
|
-
def precompile_assets
|
364
|
-
logger.info "Precompile assets..."
|
365
|
-
execute_cmd "bundle exec rake assets:precompile RAILS_ENV=#{@deployment_config['environment']}"
|
366
|
-
end
|
367
|
-
|
368
|
-
|
369
|
-
def precompile_assets_housekeeping
|
370
|
-
asset_dir = 'public/assets'
|
371
|
-
if File.exist?(asset_dir)
|
372
|
-
logger.info "Precompile assets housekeeping: remove '#{asset_dir}'"
|
373
|
-
FileUtils.rm_rf asset_dir
|
374
|
-
end
|
375
|
-
end
|
376
347
|
|
377
348
|
|
378
349
|
def execute_cmd cmd
|
379
|
-
logger.debug "Execute: #{cmd
|
350
|
+
logger.debug "Execute: #{cmd}"
|
380
351
|
rc = system(cmd)
|
381
352
|
raise("Command '#{cmd}' failed.") unless rc
|
382
353
|
end
|
383
354
|
|
384
355
|
|
356
|
+
def do_cmds name, cmd_list, server_uri=nil, local=true
|
357
|
+
return if cmd_list.nil? || cmd_list.empty?
|
358
|
+
puts "\nExecute #{name} commands..\n"
|
359
|
+
file_dir = @deployment_config['remote_dest_file_dir']
|
360
|
+
raise "Remote command required server_uri" if !local && server_uri.nil?
|
361
|
+
raise "Remote command required remote_dest_file_dir" if !local && file_dir.nil?
|
362
|
+
cmd_list.each do |cmd|
|
363
|
+
next if cmd.nil?
|
364
|
+
if cmd.start_with? '#'
|
365
|
+
puts cmd
|
366
|
+
else
|
367
|
+
if local
|
368
|
+
sys_cmd = cmd
|
369
|
+
else
|
370
|
+
sys_cmd = "ssh #{server_uri} '. .profile && cd #{file_dir} && export RAILS_ENV=#{@rails_env} && #{cmd}'"
|
371
|
+
end
|
372
|
+
execute_cmd sys_cmd
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
|
385
378
|
|
386
379
|
end
|
data/lib/osp_deploy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osp-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|