engineyard-serverside 2.7.0.pre → 2.7.8pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/engineyard-serverside +1 -1
- data/lib/engineyard-serverside/about.rb +8 -7
- data/lib/engineyard-serverside/cli.rb +225 -4
- data/lib/engineyard-serverside/cli_helpers.rb +53 -0
- data/lib/engineyard-serverside/configuration.rb +0 -1
- data/lib/engineyard-serverside/dependency_manager/bundler.rb +18 -46
- data/lib/engineyard-serverside/dependency_manager/npm.rb +1 -12
- data/lib/engineyard-serverside/deploy.rb +45 -7
- data/lib/engineyard-serverside/deploy_hook.rb +83 -20
- data/lib/engineyard-serverside/maintenance.rb +9 -1
- data/lib/engineyard-serverside/paths.rb +0 -11
- data/lib/engineyard-serverside/rails_assets.rb +1 -2
- data/lib/engineyard-serverside/version.rb +1 -1
- data/spec/archive_deploy_spec.rb +53 -0
- data/spec/basic_deploy_spec.rb +26 -0
- data/spec/bundler_deploy_spec.rb +139 -0
- data/spec/configuration_spec.rb +205 -0
- data/spec/custom_deploy_spec.rb +128 -0
- data/spec/deploy_hook_spec.rb +362 -0
- data/spec/deprecation_spec.rb +23 -0
- data/spec/ey_yml_customized_deploy_spec.rb +99 -0
- data/spec/fixtures/gitrepo.tar.gz +0 -0
- data/{lib/engineyard-serverside/callbacks/hooks.rb → spec/fixtures/gitrepo/bar} +0 -0
- data/spec/fixtures/gitrepo/foo +0 -0
- data/spec/fixtures/invalid_hook.rb +1 -0
- data/spec/fixtures/lockfiles/0.9-no-bundler +111 -0
- data/spec/fixtures/lockfiles/0.9-with-bundler +117 -0
- data/spec/fixtures/lockfiles/1.0-no-bundler +54 -0
- data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +162 -0
- data/spec/fixtures/lockfiles/1.0.18-do_mysql +88 -0
- data/spec/fixtures/lockfiles/1.0.18-do_postgres +79 -0
- data/spec/fixtures/lockfiles/1.0.18-mysql +43 -0
- data/spec/fixtures/lockfiles/1.0.18-mysql2 +43 -0
- data/spec/fixtures/lockfiles/1.0.18-pg +43 -0
- data/spec/fixtures/lockfiles/1.0.6-no-bundler +51 -0
- data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +52 -0
- data/spec/fixtures/lockfiles/1.0.6-with-bundler +52 -0
- data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +112 -0
- data/spec/fixtures/lockfiles/not-a-lockfile +1 -0
- data/spec/fixtures/repos/assets_detected/Gemfile +5 -0
- data/spec/fixtures/repos/assets_detected/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_detected/README +1 -0
- data/spec/fixtures/repos/assets_detected/Rakefile +5 -0
- data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_detected/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_detected/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile +5 -0
- data/spec/fixtures/repos/assets_disabled/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_disabled/README +1 -0
- data/spec/fixtures/repos/assets_disabled/Rakefile +6 -0
- data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_disabled/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +6 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +5 -0
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +5 -0
- data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_disabled_utf8/README +3 -0
- data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +5 -0
- data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +7 -0
- data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_enabled_all/Gemfile +5 -0
- data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_enabled_all/README +1 -0
- data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_all/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +6 -0
- data/spec/fixtures/repos/assets_enabled_all/script/assets +5 -0
- data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +1 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +3 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +10 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +1 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +8 -0
- data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +4 -0
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +5 -0
- data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_enabled_util_only/README +1 -0
- data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +6 -0
- data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +6 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile +5 -0
- data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +88 -0
- data/spec/fixtures/repos/assets_in_hook/README +2 -0
- data/spec/fixtures/repos/assets_in_hook/Rakefile +5 -0
- data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
- data/spec/fixtures/repos/assets_in_hook/config/application.rb +5 -0
- data/spec/fixtures/repos/assets_in_hook/config/ey.yml +3 -0
- data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +2 -0
- data/spec/fixtures/repos/bundle_fails/Gemfile +1 -0
- data/spec/fixtures/repos/bundle_fails/README +1 -0
- data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +1 -0
- data/spec/fixtures/repos/bundler_disabled/Gemfile +4 -0
- data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +12 -0
- data/spec/fixtures/repos/bundler_disabled/README +1 -0
- data/spec/fixtures/repos/bundler_disabled/config/ey.yml +2 -0
- data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +1 -0
- data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +1 -0
- data/spec/fixtures/repos/default/Gemfile +4 -0
- data/spec/fixtures/repos/default/Gemfile.lock +12 -0
- data/spec/fixtures/repos/default/README +5 -0
- data/spec/fixtures/repos/default/ey.yml +3 -0
- data/spec/fixtures/repos/executable_hooks/README +1 -0
- data/spec/fixtures/repos/executable_hooks/deploy/before_restart +72 -0
- data/spec/fixtures/repos/executable_hooks_not_executable/README +3 -0
- data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +3 -0
- data/spec/fixtures/repos/ey_yml/Gemfile +4 -0
- data/spec/fixtures/repos/ey_yml/Gemfile.lock +12 -0
- data/spec/fixtures/repos/ey_yml/README +1 -0
- data/spec/fixtures/repos/ey_yml/config/ey.yml +18 -0
- data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +6 -0
- data/spec/fixtures/repos/ey_yml_alt/Gemfile +4 -0
- data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +12 -0
- data/spec/fixtures/repos/ey_yml_alt/README +1 -0
- data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +6 -0
- data/spec/fixtures/repos/ey_yml_alt/ey.yml +12 -0
- data/spec/fixtures/repos/hook_fails/README +1 -0
- data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +1 -0
- data/spec/fixtures/repos/hooks/README +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_restart.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_restart.rb +1 -0
- data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +1 -0
- data/spec/fixtures/repos/multi_dep_manager/README +1 -0
- data/spec/fixtures/repos/multi_dep_manager/composer.json +5 -0
- data/spec/fixtures/repos/multi_dep_manager/composer.lock +462 -0
- data/spec/fixtures/repos/multi_dep_manager/package.json +7 -0
- data/spec/fixtures/repos/multi_dep_manager/public/index.php +4 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile +3 -0
- data/spec/fixtures/repos/no_ey_config/Gemfile.lock +10 -0
- data/spec/fixtures/repos/no_ey_config/README +1 -0
- data/spec/fixtures/repos/no_ey_config/ey.yml +3 -0
- data/spec/fixtures/repos/no_gemfile_lock/Gemfile +4 -0
- data/spec/fixtures/repos/no_gemfile_lock/README +1 -0
- data/spec/fixtures/repos/no_gemfile_lock/ey.yml +3 -0
- data/spec/fixtures/repos/nodejs/README +1 -0
- data/spec/fixtures/repos/nodejs/package.json +7 -0
- data/spec/fixtures/repos/not_bundled/README +1 -0
- data/spec/fixtures/repos/npm_disabled/README +1 -0
- data/spec/fixtures/repos/npm_disabled/config/ey.yml +2 -0
- data/spec/fixtures/repos/npm_disabled/package.json +7 -0
- data/spec/fixtures/repos/php_composer_disabled/README +1 -0
- data/spec/fixtures/repos/php_composer_disabled/composer.json +5 -0
- data/spec/fixtures/repos/php_composer_disabled/composer.lock +462 -0
- data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +2 -0
- data/spec/fixtures/repos/php_composer_disabled/public/index.php +4 -0
- data/spec/fixtures/repos/php_composer_lock/README +1 -0
- data/spec/fixtures/repos/php_composer_lock/composer.json +5 -0
- data/spec/fixtures/repos/php_composer_lock/composer.lock +462 -0
- data/spec/fixtures/repos/php_composer_lock/public/index.php +4 -0
- data/spec/fixtures/repos/php_no_composer_lock/README +1 -0
- data/spec/fixtures/repos/php_no_composer_lock/composer.json +21 -0
- data/spec/fixtures/repos/php_no_composer_lock/public/index.php +4 -0
- data/spec/fixtures/repos/public_system/Gemfile +4 -0
- data/spec/fixtures/repos/public_system/Gemfile.lock +12 -0
- data/spec/fixtures/repos/public_system/README +5 -0
- data/spec/fixtures/repos/public_system/ey.yml +3 -0
- data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +3 -0
- data/spec/fixtures/repos/sqlite3/Gemfile +4 -0
- data/spec/fixtures/repos/sqlite3/Gemfile.lock +89 -0
- data/spec/fixtures/repos/sqlite3/README +1 -0
- data/spec/fixtures/retwisj.war +0 -0
- data/spec/fixtures/valid_hook.rb +1 -0
- data/spec/git_strategy_spec.rb +34 -0
- data/spec/lockfile_parser_spec.rb +122 -0
- data/spec/maintenance_spec.rb +44 -0
- data/spec/multi_dependency_manager_spec.rb +25 -0
- data/spec/nodejs_deploy_spec.rb +30 -0
- data/spec/php_deploy_spec.rb +81 -0
- data/spec/platform_configure_spec.rb +61 -0
- data/spec/rails31_deploy_spec.rb +164 -0
- data/spec/restart_spec.rb +43 -0
- data/spec/rollback_spec.rb +87 -0
- data/spec/server_spec.rb +70 -0
- data/spec/services_deploy_spec.rb +153 -0
- data/spec/shell_spec.rb +57 -0
- data/spec/source/archive_spec.rb +33 -0
- data/spec/source/git_spec.rb +44 -0
- data/spec/spec_helper.rb +355 -0
- data/spec/sqlite3_deploy_spec.rb +38 -0
- data/spec/support/integration.rb +103 -0
- data/spec/support/source_doubles.rb +28 -0
- data/spec/support/timecop.rb +5 -0
- data/spec/symlink_spec.rb +15 -0
- metadata +522 -184
- data/lib/engineyard-serverside/callbacks.rb +0 -11
- data/lib/engineyard-serverside/callbacks/collection.rb +0 -17
- data/lib/engineyard-serverside/callbacks/collection/base.rb +0 -94
- data/lib/engineyard-serverside/callbacks/collection/combined.rb +0 -45
- data/lib/engineyard-serverside/callbacks/collection/deploy_hooks.rb +0 -21
- data/lib/engineyard-serverside/callbacks/collection/service_hooks.rb +0 -17
- data/lib/engineyard-serverside/callbacks/collection/service_hooks/collection.rb +0 -24
- data/lib/engineyard-serverside/callbacks/collection/service_hooks/combined.rb +0 -40
- data/lib/engineyard-serverside/callbacks/distributor.rb +0 -23
- data/lib/engineyard-serverside/callbacks/distributor/base.rb +0 -38
- data/lib/engineyard-serverside/callbacks/distributor/executable.rb +0 -19
- data/lib/engineyard-serverside/callbacks/distributor/executable/runnable.rb +0 -41
- data/lib/engineyard-serverside/callbacks/distributor/executable/unrunnable.rb +0 -19
- data/lib/engineyard-serverside/callbacks/distributor/ruby.rb +0 -59
- data/lib/engineyard-serverside/callbacks/distributor/ruby/distributor.rb +0 -57
- data/lib/engineyard-serverside/callbacks/hooks/app.rb +0 -17
- data/lib/engineyard-serverside/callbacks/hooks/base.rb +0 -39
- data/lib/engineyard-serverside/callbacks/hooks/service.rb +0 -24
- data/lib/engineyard-serverside/callbacks/service_hook.rb +0 -20
- data/lib/engineyard-serverside/cli/app.rb +0 -136
- data/lib/engineyard-serverside/cli/helpers.rb +0 -58
- data/lib/engineyard-serverside/cli/server_hash_extractor.rb +0 -49
- data/lib/engineyard-serverside/cli/workflows.rb +0 -45
- data/lib/engineyard-serverside/cli/workflows/base.rb +0 -78
- data/lib/engineyard-serverside/cli/workflows/calling_deploy_hooks.rb +0 -31
- data/lib/engineyard-serverside/cli/workflows/deploying_applications.rb +0 -28
- data/lib/engineyard-serverside/cli/workflows/disabling_maintenance.rb +0 -29
- data/lib/engineyard-serverside/cli/workflows/enabling_maintenance.rb +0 -29
- data/lib/engineyard-serverside/cli/workflows/errors.rb +0 -13
- data/lib/engineyard-serverside/cli/workflows/helpers.rb +0 -21
- data/lib/engineyard-serverside/cli/workflows/integrating_servers.rb +0 -71
- data/lib/engineyard-serverside/cli/workflows/restarting_applications.rb +0 -36
- data/lib/engineyard-serverside/cli/workflows/rolling_back_applications.rb +0 -28
- data/lib/engineyard-serverside/cli/workflows/showing_maintenance_status.rb +0 -28
- data/lib/engineyard-serverside/deploy_hook/callback_context.rb +0 -77
- data/lib/engineyard-serverside/propagator.rb +0 -59
- data/lib/engineyard-serverside/slug.rb +0 -7
- data/lib/engineyard-serverside/slug/distributor.rb +0 -58
- data/lib/engineyard-serverside/slug/enabler.rb +0 -100
- data/lib/engineyard-serverside/slug/failure_handler.rb +0 -24
- data/lib/engineyard-serverside/slug/finalizer.rb +0 -86
- data/lib/engineyard-serverside/slug/generator.rb +0 -29
- data/lib/engineyard-serverside/slug/migrator.rb +0 -41
- data/lib/engineyard-serverside/slug/restarter.rb +0 -103
- data/lib/engineyard-serverside/slug/source.rb +0 -16
- data/lib/engineyard-serverside/slug/source/updater.rb +0 -194
- data/lib/railway.rb +0 -43
- data/lib/result.rb +0 -7
- data/lib/result/base.rb +0 -41
- data/lib/result/dsl.rb +0 -16
- data/lib/result/failure.rb +0 -29
- data/lib/result/success.rb +0 -24
- data/lib/runner.rb +0 -34
@@ -10,18 +10,7 @@ module EY
|
|
10
10
|
|
11
11
|
def install
|
12
12
|
shell.status "Installing npm packages (package.json detected)"
|
13
|
-
run
|
14
|
-
run %{cd #{paths.active_release} && export GIT_SSH="#{ENV['GIT_SSH']}" && npm install #{npm_install_options.join(" ")}}
|
15
|
-
end
|
16
|
-
|
17
|
-
def npm_install_options
|
18
|
-
options = []
|
19
|
-
options += ['--production'] if npm_production?
|
20
|
-
options
|
21
|
-
end
|
22
|
-
|
23
|
-
def npm_production?
|
24
|
-
ENV['NODE_ENV'] == 'production'
|
13
|
+
run %{cd #{paths.active_release} && export GIT_SSH="#{ENV['GIT_SSH']}" && npm install}
|
25
14
|
end
|
26
15
|
end
|
27
16
|
end
|
@@ -5,7 +5,6 @@ require 'engineyard-serverside/rails_assets'
|
|
5
5
|
require 'engineyard-serverside/maintenance'
|
6
6
|
require 'engineyard-serverside/dependency_manager'
|
7
7
|
require 'engineyard-serverside/dependency_manager/legacy_helpers'
|
8
|
-
require 'engineyard-serverside/callbacks'
|
9
8
|
|
10
9
|
module EY
|
11
10
|
module Serverside
|
@@ -451,9 +450,27 @@ defaults:
|
|
451
450
|
end
|
452
451
|
|
453
452
|
def callback(what)
|
454
|
-
load_callbacks
|
455
453
|
@callbacks_reached ||= true
|
456
|
-
|
454
|
+
|
455
|
+
if paths.deploy_hook(what).exist?
|
456
|
+
shell.status "Running deploy hook: deploy/#{what}.rb"
|
457
|
+
run Escape.shell_command(base_callback_command_for(what)) do |server, cmd|
|
458
|
+
per_instance_args = []
|
459
|
+
per_instance_args << '--current-roles' << server.roles.to_a.join(' ')
|
460
|
+
per_instance_args << '--current-name' << server.name.to_s if server.name
|
461
|
+
per_instance_args << '--config' << config.to_json
|
462
|
+
cmd << " " << Escape.shell_command(per_instance_args)
|
463
|
+
end
|
464
|
+
elsif paths.executable_deploy_hook(what).executable?
|
465
|
+
shell.status "Running deploy hook: deploy/#{what}"
|
466
|
+
run [About.hook_executor, what.to_s].join(' ') do |server, cmd|
|
467
|
+
cmd = hook_env_vars(server).reject{|k,v| v.nil?}.map{|k,v|
|
468
|
+
"#{k}=#{Escape.shell_command([v])}"
|
469
|
+
}.join(' ') + ' ' + config.framework_envs + ' ' + cmd
|
470
|
+
end
|
471
|
+
elsif paths.executable_deploy_hook(what).exist?
|
472
|
+
shell.warning "Skipping possible deploy hook deploy/#{what} because it is not executable."
|
473
|
+
end
|
457
474
|
end
|
458
475
|
|
459
476
|
def source
|
@@ -463,6 +480,31 @@ defaults:
|
|
463
480
|
|
464
481
|
protected
|
465
482
|
|
483
|
+
def base_callback_command_for(what)
|
484
|
+
cmd = [About.binary, 'hook', what.to_s]
|
485
|
+
cmd << '--app' << config.app
|
486
|
+
cmd << '--environment-name' << config.environment_name
|
487
|
+
cmd << '--account-name' << config.account_name
|
488
|
+
cmd << '--release-path' << paths.active_release.to_s
|
489
|
+
cmd << '--framework-env' << config.framework_env.to_s
|
490
|
+
cmd << '--verbose' if config.verbose
|
491
|
+
cmd
|
492
|
+
end
|
493
|
+
|
494
|
+
def hook_env_vars(server)
|
495
|
+
{
|
496
|
+
'EY_DEPLOY_ACCOUNT_NAME' => config.account_name,
|
497
|
+
'EY_DEPLOY_APP' => config.app,
|
498
|
+
'EY_DEPLOY_CONFIG' => config.to_json,
|
499
|
+
'EY_DEPLOY_CURRENT_ROLES' => server.roles.to_a.join(' '),
|
500
|
+
'EY_DEPLOY_CURRENT_NAME' => server.name ? server.name.to_s : nil,
|
501
|
+
'EY_DEPLOY_ENVIRONMENT_NAME' => config.environment_name,
|
502
|
+
'EY_DEPLOY_FRAMEWORK_ENV' => config.framework_env.to_s,
|
503
|
+
'EY_DEPLOY_RELEASE_PATH' => paths.active_release.to_s,
|
504
|
+
'EY_DEPLOY_VERBOSE' => (config.verbose ? '1' : '0'),
|
505
|
+
}
|
506
|
+
end
|
507
|
+
|
466
508
|
# FIXME: Legacy method, warn and remove.
|
467
509
|
def serverside_bin
|
468
510
|
About.binary
|
@@ -512,10 +554,6 @@ defaults:
|
|
512
554
|
def compile_assets
|
513
555
|
RailsAssets.detect_and_compile(config, shell, self)
|
514
556
|
end
|
515
|
-
|
516
|
-
def load_callbacks
|
517
|
-
@callbacks_collection ||= Callbacks.load(paths)
|
518
|
-
end
|
519
557
|
end # DeployBase
|
520
558
|
|
521
559
|
class Deploy < DeployBase
|
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'engineyard-serverside/shell/helpers'
|
2
|
-
require 'engineyard-serverside/deploy_hook/callback_context'
|
3
|
-
require 'engineyard-serverside/callbacks'
|
4
2
|
require 'rbconfig'
|
5
3
|
|
6
4
|
module EY
|
@@ -12,32 +10,36 @@ module EY
|
|
12
10
|
@config, @shell, @hook_name = config, shell, hook_name
|
13
11
|
end
|
14
12
|
|
13
|
+
def hook_path
|
14
|
+
config.paths.deploy_hook(hook_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def callback_context
|
18
|
+
@context ||= CallbackContext.new(config, shell, hook_path)
|
19
|
+
end
|
20
|
+
|
15
21
|
def call
|
16
|
-
|
22
|
+
if hook_path.exist?
|
17
23
|
Dir.chdir(config.paths.active_release.to_s) do
|
18
|
-
if desc = syntax_error(
|
19
|
-
hook_name =
|
24
|
+
if desc = syntax_error(hook_path)
|
25
|
+
hook_name = hook_path.basename
|
20
26
|
abort "*** [Error] Invalid Ruby syntax in hook: #{hook_name} ***\n*** #{desc.chomp} ***"
|
21
27
|
else
|
22
|
-
eval_hook(
|
28
|
+
eval_hook(hook_path.read)
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
def eval_hook(code
|
29
|
-
|
30
|
-
|
31
|
-
display_deprecation_warnings(code, hook_path)
|
32
|
-
CallbackContext.
|
33
|
-
new(config, shell, hook_path).
|
34
|
-
instance_eval(code)
|
34
|
+
def eval_hook(code)
|
35
|
+
display_deprecation_warnings(code)
|
36
|
+
callback_context.instance_eval(code)
|
35
37
|
rescue Exception => exception
|
36
38
|
display_hook_error(exception, code, hook_path)
|
37
39
|
raise exception
|
38
40
|
end
|
39
41
|
|
40
|
-
def display_deprecation_warnings(code
|
42
|
+
def display_deprecation_warnings(code)
|
41
43
|
if code =~ /@configuration/
|
42
44
|
shell.warning("Use of `@configuration` in deploy hooks is deprecated.\nPlease use `config`, which provides access to the same object.\n\tin #{hook_path}")
|
43
45
|
end
|
@@ -66,12 +68,73 @@ Please fix this error before retrying.
|
|
66
68
|
output unless output =~ /Syntax OK/
|
67
69
|
end
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
class CallbackContext
|
72
|
+
include EY::Serverside::Shell::Helpers
|
73
|
+
|
74
|
+
attr_reader :shell, :hook_path
|
75
|
+
|
76
|
+
def initialize(config, shell, hook_path)
|
77
|
+
@configuration = config
|
78
|
+
@configuration.set_framework_envs
|
79
|
+
@shell = shell
|
80
|
+
@node = config.node
|
81
|
+
@hook_path = hook_path
|
82
|
+
end
|
83
|
+
|
84
|
+
def config
|
85
|
+
@configuration
|
86
|
+
end
|
87
|
+
|
88
|
+
def inspect
|
89
|
+
"#<DeployHook::CallbackContext #{hook_path.inspect}>"
|
90
|
+
end
|
91
|
+
|
92
|
+
def method_missing(meth, *args, &blk)
|
93
|
+
if @configuration.respond_to?(meth)
|
94
|
+
shell.warning "Use of `#{meth}` (via method_missing) is deprecated in favor of `config.#{meth}` for improved error messages and compatibility.\n\tin #{hook_path}"
|
95
|
+
@configuration.send(meth, *args, &blk)
|
96
|
+
else
|
97
|
+
super
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def respond_to?(*a)
|
102
|
+
@configuration.respond_to?(*a) || super
|
103
|
+
end
|
104
|
+
|
105
|
+
def run(cmd)
|
106
|
+
shell.logged_system(Escape.shell_command(["sh", "-l", "-c", cmd])).success?
|
107
|
+
end
|
108
|
+
|
109
|
+
def run!(cmd)
|
110
|
+
run(cmd) or raise("run!: Command failed. #{cmd}")
|
111
|
+
end
|
112
|
+
|
113
|
+
def sudo(cmd)
|
114
|
+
shell.logged_system(Escape.shell_command(["sudo", "sh", "-l", "-c", cmd])).success?
|
115
|
+
end
|
116
|
+
|
117
|
+
def sudo!(cmd)
|
118
|
+
sudo(cmd) or raise("sudo!: Command failed. #{cmd}")
|
119
|
+
end
|
120
|
+
|
121
|
+
# convenience functions for running on certain instance types
|
122
|
+
def on_app_master(&blk) on_roles(%w[solo app_master], &blk) end
|
123
|
+
def on_app_servers(&blk) on_roles(%w[solo app_master app], &blk) end
|
124
|
+
def on_app_servers_and_utilities(&blk) on_roles(%w[solo app_master app util], &blk) end
|
125
|
+
|
126
|
+
def on_utilities(*names, &blk)
|
127
|
+
names.flatten!
|
128
|
+
on_roles(%w[util]) do
|
129
|
+
blk.call if names.empty? || names.include?(config.current_name)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
def on_roles(desired_roles)
|
135
|
+
yield if desired_roles.any? { |role| config.current_roles.include?(role) }
|
136
|
+
end
|
137
|
+
|
75
138
|
end
|
76
139
|
|
77
140
|
end
|
@@ -70,7 +70,15 @@ module EY
|
|
70
70
|
run "mkdir -p #{maintenance_page_dirname}"
|
71
71
|
public_system_symlink_warning
|
72
72
|
@up = true
|
73
|
-
|
73
|
+
maintenance_page_html = File.read(source_path)
|
74
|
+
if source_path == EY::Serverside::Paths::DEFAULT_MAINTENANCE_PAGE
|
75
|
+
#run fans out to all app servers but the serverside version is only isntalled on the server being used to deploy
|
76
|
+
#so if the serveside version being used isn't installed on a given app server the cp command would fail, but this echo will still work
|
77
|
+
run "echo '#{maintenance_page_html}' > #{enabled_maintenance_page_pathname}"
|
78
|
+
else
|
79
|
+
#since other possible paths are in your app, cp should work
|
80
|
+
run "cp #{source_path} #{enabled_maintenance_page_pathname}"
|
81
|
+
end
|
74
82
|
end
|
75
83
|
|
76
84
|
def disable
|
@@ -68,8 +68,6 @@ module EY
|
|
68
68
|
def_path :shared_log, [:shared, 'log']
|
69
69
|
def_path :shared_tmp, [:shared, 'tmp']
|
70
70
|
def_path :shared_config, [:shared, 'config']
|
71
|
-
def_path :shared_hooks, [:shared, 'hooks']
|
72
|
-
def_path :shared_node_modules, [:shared, 'node_modules']
|
73
71
|
def_path :shared_system, [:shared, 'system']
|
74
72
|
def_path :default_repository_cache, [:shared, 'cached-copy']
|
75
73
|
def_path :enabled_maintenance_page, [:shared_system, 'maintenance.html']
|
@@ -92,7 +90,6 @@ module EY
|
|
92
90
|
def_path :composer_lock, [:active_release, 'composer.lock']
|
93
91
|
def_path :active_release_config, [:active_release, 'config']
|
94
92
|
def_path :active_log, [:active_release, 'log']
|
95
|
-
def_path :active_node_modules, [:active_release, 'node_modules']
|
96
93
|
def_path :active_tmp, [:active_release, 'tmp']
|
97
94
|
|
98
95
|
def initialize(opts)
|
@@ -131,18 +128,10 @@ module EY
|
|
131
128
|
path(:deploy_hooks, "#{hook_name}.rb")
|
132
129
|
end
|
133
130
|
|
134
|
-
def service_hook(service_name, hook_name)
|
135
|
-
path(:shared_hooks, service_name, "#{hook_name}.rb")
|
136
|
-
end
|
137
|
-
|
138
131
|
def executable_deploy_hook(hook_name)
|
139
132
|
path(:deploy_hooks, "#{hook_name}")
|
140
133
|
end
|
141
134
|
|
142
|
-
def executable_service_hook(service_name, hook_name)
|
143
|
-
path(:shared_hooks, service_name, "#{hook_name}")
|
144
|
-
end
|
145
|
-
|
146
135
|
def repository_cache
|
147
136
|
@repository_cache ||= default_repository_cache
|
148
137
|
end
|
@@ -58,8 +58,7 @@ module EY
|
|
58
58
|
# This is a hack right now, but I haven't iterated over it enough for a good solution yet.
|
59
59
|
if config.experimental_sync_assets?
|
60
60
|
shell.status "Compiling assets once on localhost (experimental_sync_assets: true)"
|
61
|
-
|
62
|
-
raise "Assets compilation error" unless compilation_result.success?
|
61
|
+
shell.logged_system("sh -l -c '#{cd} && #{task}'")
|
63
62
|
|
64
63
|
shell.status "Syncing assets to other remote servers (experimental_sync_assets: true)"
|
65
64
|
runner.servers.remote.run_for_each do |server|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class EY::Serverside::Source::Archive
|
4
|
+
def fetch_command
|
5
|
+
"cp #{uri} #{source_cache}"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Deploying a simple application" do
|
10
|
+
|
11
|
+
before(:all) do
|
12
|
+
adapter = EY::Serverside::Adapter.new do |args|
|
13
|
+
args.account_name = "account"
|
14
|
+
args.app = "application_name"
|
15
|
+
args.stack = "nginx_unicorn"
|
16
|
+
args.environment_name = "environment_name"
|
17
|
+
args.framework_env = "production"
|
18
|
+
args.archive = FIXTURES_DIR.join('retwisj.war')
|
19
|
+
args.verbose = true
|
20
|
+
args.instances = [{ :hostname => "localhost", :roles => ["solo"], :name => "single" }]
|
21
|
+
args.serverside_version = Gem::Version.create(EY::Serverside::VERSION.dup).release
|
22
|
+
args.config = {
|
23
|
+
"deploy_to" => deploy_dir.to_s,
|
24
|
+
"group" => GROUP
|
25
|
+
}
|
26
|
+
end
|
27
|
+
argv = adapter.deploy.commands.last.to_argv[2..-1]
|
28
|
+
with_mocked_commands do
|
29
|
+
capture do
|
30
|
+
EY::Serverside::CLI.start(argv)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "exploded the war" do
|
36
|
+
%w(META-INF WEB-INF).each {|dir|
|
37
|
+
File.exists?(deploy_dir.join('current', dir))
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "creates a REVISION file" do
|
42
|
+
path = deploy_dir.join('current', 'REVISION')
|
43
|
+
expect(path).to exist
|
44
|
+
checksum = File.read(path).strip
|
45
|
+
expect(checksum).to match(/7400dc058376745c11a98f768b799c6651428857\s+.*retwisj.war$/)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "restarts the app servers" do
|
49
|
+
restart = deploy_dir.join('current', 'restart')
|
50
|
+
expect(restart).to exist
|
51
|
+
expect(restart.read.chomp).to eq(%|LANG="en_US.UTF-8" /engineyard/bin/app_application_name deploy|)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Deploying a simple application" do
|
4
|
+
before(:all) do
|
5
|
+
deploy_test_application('not_bundled')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "creates a REVISION file" do
|
9
|
+
expect(deploy_dir.join('current', 'REVISION')).to exist
|
10
|
+
end
|
11
|
+
|
12
|
+
it "restarts the app servers" do
|
13
|
+
restart = deploy_dir.join('current', 'restart')
|
14
|
+
expect(restart).to exist
|
15
|
+
expect(restart.read.chomp).to eq(%|LANG="en_US.UTF-8" /engineyard/bin/app_rails31 deploy|)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "reuses the same active_release directory if a release_path is specified (such as in integrate)" do
|
19
|
+
path = @config.paths.active_release
|
20
|
+
expect(path.parent.children.size).to eq(1)
|
21
|
+
|
22
|
+
redeploy_test_application('config' => {'release_path' => path.to_s})
|
23
|
+
|
24
|
+
expect(path.parent.children.size).to eq(1)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Deploying an application that uses Bundler" do
|
4
|
+
VERSION_PATTERN = Regexp.quote(::EY::Serverside::DependencyManager::Bundler.default_version)
|
5
|
+
|
6
|
+
context "with a Gemfile.lock" do
|
7
|
+
before(:all) do
|
8
|
+
deploy_test_application('ey_yml')
|
9
|
+
@install_bundler_command = @deployer.commands.grep(/gem install bundler/).first
|
10
|
+
@bundle_install_command = @deployer.commands.grep(/bundle _#{VERSION_PATTERN}_ install/).first
|
11
|
+
end
|
12
|
+
|
13
|
+
it "runs the right bundler command" do
|
14
|
+
expect(@install_bundler_command).not_to be_nil
|
15
|
+
expect(@install_bundler_command).to match(/install bundler .* -v "#{VERSION_PATTERN}"/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "runs 'bundle install' with --deployment" do
|
19
|
+
expect(@bundle_install_command).not_to be_nil
|
20
|
+
expect(@bundle_install_command).to include('--deployment')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "removes bundled_gems directory if the ruby or system version changed" do
|
24
|
+
should_run_clear_bundle_cmd = @deployer.commands.grep(/diff/).first
|
25
|
+
expect(should_run_clear_bundle_cmd).not_to be_nil
|
26
|
+
clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
|
27
|
+
expect(clear_bundle_cmd).not_to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "has the binstubs in the path when migrating" do
|
31
|
+
expect(deploy_dir.join('path-when-migrating').read).to include('ey_bundler_binstubs')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "creates a ruby version file" do
|
35
|
+
expect(deploy_dir.join('shared', 'bundled_gems', 'RUBY_VERSION')).to exist
|
36
|
+
end
|
37
|
+
|
38
|
+
it "creates a system version file" do
|
39
|
+
expect(deploy_dir.join('shared', 'bundled_gems', 'SYSTEM_VERSION')).to exist
|
40
|
+
end
|
41
|
+
|
42
|
+
it "generates bundler binstubs" do
|
43
|
+
pending "doesn't work with mocked bundler"
|
44
|
+
expect(deploy_dir.join('current', 'ey_bundler_binstubs', 'rake')).to exist
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with clean option" do
|
49
|
+
before(:all) do
|
50
|
+
deploy_test_application('ey_yml', 'clean' => true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "removes bundled_gems directory if the ruby or system version changed" do
|
54
|
+
should_run_clear_bundle_cmd = @deployer.commands.grep(/diff/).first
|
55
|
+
expect(should_run_clear_bundle_cmd).to be_nil
|
56
|
+
clear_bundle_cmd = @deployer.commands.grep(/rm -Rf \S+\/bundled_gems/).first
|
57
|
+
expect(clear_bundle_cmd).not_to be_nil
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context "with bundler disabled in ey.yml" do
|
63
|
+
before(:all) do
|
64
|
+
deploy_test_application('bundler_disabled')
|
65
|
+
end
|
66
|
+
|
67
|
+
it "does not run bundler commands" do
|
68
|
+
expect(@deployer.commands.grep(/gem install bundler/)).to be_empty
|
69
|
+
expect(@deployer.commands.grep(/bundle _.*_ install/)).to be_empty
|
70
|
+
end
|
71
|
+
|
72
|
+
it "still runs the hooks" do
|
73
|
+
expect(deploy_dir.join('current', 'before_bundle.ran' )).to exist
|
74
|
+
expect(deploy_dir.join('current', 'after_bundle.ran' )).to exist
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "without a Gemfile.lock" do
|
79
|
+
before(:all) do
|
80
|
+
deploy_test_application('no_gemfile_lock')
|
81
|
+
@install_bundler_command = @deployer.commands.grep(/gem install bundler/).first
|
82
|
+
@bundle_install_command = @deployer.commands.grep(/bundle _#{VERSION_PATTERN}_ install/).first
|
83
|
+
end
|
84
|
+
|
85
|
+
it "installs the proper Bundler version" do
|
86
|
+
expect(@install_bundler_command).not_to be_nil
|
87
|
+
expect(@install_bundler_command).to match(/unset RUBYOPT && gem list bundler | grep "bundler " | egrep -q "#{VERSION_PATTERN}[,)]" || gem install bundler -q --no-rdoc --no-ri -v "#{VERSION_PATTERN}"/)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "runs 'bundle install' without --deployment" do
|
91
|
+
expect(@bundle_install_command).not_to be_nil
|
92
|
+
expect(@bundle_install_command).not_to match(/--deployment/)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "exports GIT_SSH for the bundle install" do
|
96
|
+
expect(@bundle_install_command).to match(/export GIT_SSH/)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "puts down RUBY_VERSION and SYSTEM_VERSION" do
|
100
|
+
expect(deploy_dir.join('shared', 'bundled_gems', 'RUBY_VERSION')).to exist
|
101
|
+
expect(deploy_dir.join('shared', 'bundled_gems', 'SYSTEM_VERSION')).to exist
|
102
|
+
end
|
103
|
+
|
104
|
+
it "warns that using a lockfile is idiomatic" do
|
105
|
+
out = read_output
|
106
|
+
expect(out).to match(/WARNING: Gemfile found but Gemfile.lock is missing!/)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "without a Gemfile.lock and ignoring the warning" do
|
111
|
+
before(:all) do
|
112
|
+
deploy_test_application('no_gemfile_lock', 'config' => {'ignore_gemfile_lock_warning' => true})
|
113
|
+
expect(@config.ignore_gemfile_lock_warning).to be_truthy
|
114
|
+
@install_bundler_command = @deployer.commands.grep(/gem install bundler/).first
|
115
|
+
@bundle_install_command = @deployer.commands.grep(/bundle _#{VERSION_PATTERN}_ install/).first
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should not warn" do
|
119
|
+
out = read_output
|
120
|
+
expect(out).not_to match(/WARNING/)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "with a failing Gemfile" do
|
125
|
+
before(:all) do
|
126
|
+
begin
|
127
|
+
deploy_test_application('bundle_fails', 'bundle_install_fails' => true, 'verbose' => false)
|
128
|
+
rescue EY::Serverside::RemoteFailure
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it "prints the failure to the log" do
|
133
|
+
out = read_output
|
134
|
+
expect(out).to match(%r|bundle install failure|)
|
135
|
+
expect(deploy_dir.join('current', 'after_bundle.ran' )).not_to exist
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|