@@ -124,6 +124,22 @@ namespace :magento do
124
124
end
125
125
end
126
126
127
+ desc 'Run composer dump-autoload'
128
+ task 'dump-autoload' do
129
+
130
+ on release_roles :all do
131
+ within release_path do
132
+ composer_flags = '--no-dev --no-interaction'
133
+
134
+ if fetch ( :magento_deploy_production )
135
+ composer_flags += ' --optimize'
136
+ end
137
+
138
+ execute :composer , "dump-autoload #{ composer_flags } 2>&1"
139
+ end
140
+ end
141
+ end
142
+
127
143
task :auth_config do
128
144
on release_roles :all do
129
145
within release_path do
@@ -382,7 +398,60 @@ namespace :magento do
382
398
end
383
399
end
384
400
end
385
-
401
+
402
+ # Internal command used to check if maintenance mode is neeeded and disable when zero-down deploy is possible
403
+ task :check do
404
+ on primary fetch ( :magento_deploy_setup_role ) do
405
+ within release_path do
406
+ # Do not disable maintenance mode by default; require a postive id on database status output
407
+ disable_maintenance = false
408
+
409
+ # The setup:db:status command is only available in Magento 2.2.2 and later
410
+ if not test :magento , 'setup:db:status --help >/dev/null 2>&1'
411
+ info "Magento CLI command setup:db:status is not available. Maintenance mode will be used by default."
412
+ else
413
+ info "Checking database status..."
414
+ # Check setup:db:status output and disable maintenance mode if all modules are up-to-date
415
+ database_status = capture :magento , 'setup:db:status' , raise_on_non_zero_exit : false
416
+
417
+ if database_status . to_s . include? 'All modules are up to date'
418
+ info "All modules are up to date. No database updates should occur during this release."
419
+ puts ""
420
+ disable_maintenance = true
421
+ else
422
+ puts " #{ database_status . gsub ( "\n " , "\n " ) . sub ( "Run 'setup:upgrade' to update your DB schema and data." , "" ) } "
423
+ end
424
+
425
+ # Gather md5sums of app/etc/config.php on current and new release
426
+ config_hash_release = capture :md5sum , "#{ release_path } /app/etc/config.php"
427
+ if test "[ -f #{ current_path } /app/etc/config.php ]"
428
+ config_hash_current = capture :md5sum , "#{ current_path } /app/etc/config.php"
429
+ else
430
+ config_hash_current = ( "%-34s" % "n/a" ) + "#{ current_path } /app/etc/config.php"
431
+ end
432
+
433
+ # Output some informational messages showing the config.php hash values
434
+ info "<release_path>/app/etc/config.php hash: #{ config_hash_release . split ( " " ) [ 0 ] } "
435
+ info "<current_path>/app/etc/config.php hash: #{ config_hash_current . split ( " " ) [ 0 ] } "
436
+ info ""
437
+
438
+ # If hashes differ, maintenance mode should not be disabled even if there are no database changes.
439
+ if config_hash_release . split ( " " ) [ 0 ] != config_hash_current . split ( " " ) [ 0 ]
440
+ info "Configuration hashes do not match. Maintenance mode will be used by default."
441
+ disable_maintenance = false
442
+ end
443
+
444
+ if disable_maintenance
445
+ info "Disabling use of maintenance mode for a zero-down deployment."
446
+ set :magento_deploy_maintenance , false
447
+ else
448
+ info "Maintenance mode usage will be enforced per :magento_deploy_maintenance (enabled by default)"
449
+ end
450
+ end
451
+ end
452
+ end
453
+ end
454
+
386
455
desc 'Disable maintenance mode'
387
456
task :disable do
388
457
on release_roles :all do
0 commit comments