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.
Files changed (252) hide show
  1. data/bin/engineyard-serverside +1 -1
  2. data/lib/engineyard-serverside/about.rb +8 -7
  3. data/lib/engineyard-serverside/cli.rb +225 -4
  4. data/lib/engineyard-serverside/cli_helpers.rb +53 -0
  5. data/lib/engineyard-serverside/configuration.rb +0 -1
  6. data/lib/engineyard-serverside/dependency_manager/bundler.rb +18 -46
  7. data/lib/engineyard-serverside/dependency_manager/npm.rb +1 -12
  8. data/lib/engineyard-serverside/deploy.rb +45 -7
  9. data/lib/engineyard-serverside/deploy_hook.rb +83 -20
  10. data/lib/engineyard-serverside/maintenance.rb +9 -1
  11. data/lib/engineyard-serverside/paths.rb +0 -11
  12. data/lib/engineyard-serverside/rails_assets.rb +1 -2
  13. data/lib/engineyard-serverside/version.rb +1 -1
  14. data/spec/archive_deploy_spec.rb +53 -0
  15. data/spec/basic_deploy_spec.rb +26 -0
  16. data/spec/bundler_deploy_spec.rb +139 -0
  17. data/spec/configuration_spec.rb +205 -0
  18. data/spec/custom_deploy_spec.rb +128 -0
  19. data/spec/deploy_hook_spec.rb +362 -0
  20. data/spec/deprecation_spec.rb +23 -0
  21. data/spec/ey_yml_customized_deploy_spec.rb +99 -0
  22. data/spec/fixtures/gitrepo.tar.gz +0 -0
  23. data/{lib/engineyard-serverside/callbacks/hooks.rb → spec/fixtures/gitrepo/bar} +0 -0
  24. data/spec/fixtures/gitrepo/foo +0 -0
  25. data/spec/fixtures/invalid_hook.rb +1 -0
  26. data/spec/fixtures/lockfiles/0.9-no-bundler +111 -0
  27. data/spec/fixtures/lockfiles/0.9-with-bundler +117 -0
  28. data/spec/fixtures/lockfiles/1.0-no-bundler +54 -0
  29. data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +162 -0
  30. data/spec/fixtures/lockfiles/1.0.18-do_mysql +88 -0
  31. data/spec/fixtures/lockfiles/1.0.18-do_postgres +79 -0
  32. data/spec/fixtures/lockfiles/1.0.18-mysql +43 -0
  33. data/spec/fixtures/lockfiles/1.0.18-mysql2 +43 -0
  34. data/spec/fixtures/lockfiles/1.0.18-pg +43 -0
  35. data/spec/fixtures/lockfiles/1.0.6-no-bundler +51 -0
  36. data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +52 -0
  37. data/spec/fixtures/lockfiles/1.0.6-with-bundler +52 -0
  38. data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +112 -0
  39. data/spec/fixtures/lockfiles/not-a-lockfile +1 -0
  40. data/spec/fixtures/repos/assets_detected/Gemfile +5 -0
  41. data/spec/fixtures/repos/assets_detected/Gemfile.lock +88 -0
  42. data/spec/fixtures/repos/assets_detected/README +1 -0
  43. data/spec/fixtures/repos/assets_detected/Rakefile +5 -0
  44. data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
  45. data/spec/fixtures/repos/assets_detected/config/application.rb +5 -0
  46. data/spec/fixtures/repos/assets_detected/config/ey.yml +3 -0
  47. data/spec/fixtures/repos/assets_disabled/Gemfile +5 -0
  48. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +88 -0
  49. data/spec/fixtures/repos/assets_disabled/README +1 -0
  50. data/spec/fixtures/repos/assets_disabled/Rakefile +6 -0
  51. data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
  52. data/spec/fixtures/repos/assets_disabled/config/application.rb +5 -0
  53. data/spec/fixtures/repos/assets_disabled/config/ey.yml +3 -0
  54. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +5 -0
  55. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +88 -0
  56. data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +1 -0
  57. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +6 -0
  58. data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
  59. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +5 -0
  60. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +5 -0
  61. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +5 -0
  62. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +88 -0
  63. data/spec/fixtures/repos/assets_disabled_utf8/README +3 -0
  64. data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +5 -0
  65. data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
  66. data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +7 -0
  67. data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +3 -0
  68. data/spec/fixtures/repos/assets_enabled_all/Gemfile +5 -0
  69. data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +88 -0
  70. data/spec/fixtures/repos/assets_enabled_all/README +1 -0
  71. data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
  72. data/spec/fixtures/repos/assets_enabled_all/config/application.rb +5 -0
  73. data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +6 -0
  74. data/spec/fixtures/repos/assets_enabled_all/script/assets +5 -0
  75. data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +1 -0
  76. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +3 -0
  77. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +10 -0
  78. data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +1 -0
  79. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +8 -0
  80. data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +4 -0
  81. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +5 -0
  82. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +88 -0
  83. data/spec/fixtures/repos/assets_enabled_util_only/README +1 -0
  84. data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +6 -0
  85. data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
  86. data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +5 -0
  87. data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +6 -0
  88. data/spec/fixtures/repos/assets_in_hook/Gemfile +5 -0
  89. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +88 -0
  90. data/spec/fixtures/repos/assets_in_hook/README +2 -0
  91. data/spec/fixtures/repos/assets_in_hook/Rakefile +5 -0
  92. data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
  93. data/spec/fixtures/repos/assets_in_hook/config/application.rb +5 -0
  94. data/spec/fixtures/repos/assets_in_hook/config/ey.yml +3 -0
  95. data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +2 -0
  96. data/spec/fixtures/repos/bundle_fails/Gemfile +1 -0
  97. data/spec/fixtures/repos/bundle_fails/README +1 -0
  98. data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +1 -0
  99. data/spec/fixtures/repos/bundler_disabled/Gemfile +4 -0
  100. data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +12 -0
  101. data/spec/fixtures/repos/bundler_disabled/README +1 -0
  102. data/spec/fixtures/repos/bundler_disabled/config/ey.yml +2 -0
  103. data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +1 -0
  104. data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +1 -0
  105. data/spec/fixtures/repos/default/Gemfile +4 -0
  106. data/spec/fixtures/repos/default/Gemfile.lock +12 -0
  107. data/spec/fixtures/repos/default/README +5 -0
  108. data/spec/fixtures/repos/default/ey.yml +3 -0
  109. data/spec/fixtures/repos/executable_hooks/README +1 -0
  110. data/spec/fixtures/repos/executable_hooks/deploy/before_restart +72 -0
  111. data/spec/fixtures/repos/executable_hooks_not_executable/README +3 -0
  112. data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +3 -0
  113. data/spec/fixtures/repos/ey_yml/Gemfile +4 -0
  114. data/spec/fixtures/repos/ey_yml/Gemfile.lock +12 -0
  115. data/spec/fixtures/repos/ey_yml/README +1 -0
  116. data/spec/fixtures/repos/ey_yml/config/ey.yml +18 -0
  117. data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +6 -0
  118. data/spec/fixtures/repos/ey_yml_alt/Gemfile +4 -0
  119. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +12 -0
  120. data/spec/fixtures/repos/ey_yml_alt/README +1 -0
  121. data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +6 -0
  122. data/spec/fixtures/repos/ey_yml_alt/ey.yml +12 -0
  123. data/spec/fixtures/repos/hook_fails/README +1 -0
  124. data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +1 -0
  125. data/spec/fixtures/repos/hooks/README +1 -0
  126. data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +1 -0
  127. data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +1 -0
  128. data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +1 -0
  129. data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +1 -0
  130. data/spec/fixtures/repos/hooks/deploy/after_restart.rb +1 -0
  131. data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +1 -0
  132. data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +1 -0
  133. data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +1 -0
  134. data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +1 -0
  135. data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +1 -0
  136. data/spec/fixtures/repos/hooks/deploy/before_restart.rb +1 -0
  137. data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +1 -0
  138. data/spec/fixtures/repos/multi_dep_manager/README +1 -0
  139. data/spec/fixtures/repos/multi_dep_manager/composer.json +5 -0
  140. data/spec/fixtures/repos/multi_dep_manager/composer.lock +462 -0
  141. data/spec/fixtures/repos/multi_dep_manager/package.json +7 -0
  142. data/spec/fixtures/repos/multi_dep_manager/public/index.php +4 -0
  143. data/spec/fixtures/repos/no_ey_config/Gemfile +3 -0
  144. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +10 -0
  145. data/spec/fixtures/repos/no_ey_config/README +1 -0
  146. data/spec/fixtures/repos/no_ey_config/ey.yml +3 -0
  147. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +4 -0
  148. data/spec/fixtures/repos/no_gemfile_lock/README +1 -0
  149. data/spec/fixtures/repos/no_gemfile_lock/ey.yml +3 -0
  150. data/spec/fixtures/repos/nodejs/README +1 -0
  151. data/spec/fixtures/repos/nodejs/package.json +7 -0
  152. data/spec/fixtures/repos/not_bundled/README +1 -0
  153. data/spec/fixtures/repos/npm_disabled/README +1 -0
  154. data/spec/fixtures/repos/npm_disabled/config/ey.yml +2 -0
  155. data/spec/fixtures/repos/npm_disabled/package.json +7 -0
  156. data/spec/fixtures/repos/php_composer_disabled/README +1 -0
  157. data/spec/fixtures/repos/php_composer_disabled/composer.json +5 -0
  158. data/spec/fixtures/repos/php_composer_disabled/composer.lock +462 -0
  159. data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +2 -0
  160. data/spec/fixtures/repos/php_composer_disabled/public/index.php +4 -0
  161. data/spec/fixtures/repos/php_composer_lock/README +1 -0
  162. data/spec/fixtures/repos/php_composer_lock/composer.json +5 -0
  163. data/spec/fixtures/repos/php_composer_lock/composer.lock +462 -0
  164. data/spec/fixtures/repos/php_composer_lock/public/index.php +4 -0
  165. data/spec/fixtures/repos/php_no_composer_lock/README +1 -0
  166. data/spec/fixtures/repos/php_no_composer_lock/composer.json +21 -0
  167. data/spec/fixtures/repos/php_no_composer_lock/public/index.php +4 -0
  168. data/spec/fixtures/repos/public_system/Gemfile +4 -0
  169. data/spec/fixtures/repos/public_system/Gemfile.lock +12 -0
  170. data/spec/fixtures/repos/public_system/README +5 -0
  171. data/spec/fixtures/repos/public_system/ey.yml +3 -0
  172. data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +3 -0
  173. data/spec/fixtures/repos/sqlite3/Gemfile +4 -0
  174. data/spec/fixtures/repos/sqlite3/Gemfile.lock +89 -0
  175. data/spec/fixtures/repos/sqlite3/README +1 -0
  176. data/spec/fixtures/retwisj.war +0 -0
  177. data/spec/fixtures/valid_hook.rb +1 -0
  178. data/spec/git_strategy_spec.rb +34 -0
  179. data/spec/lockfile_parser_spec.rb +122 -0
  180. data/spec/maintenance_spec.rb +44 -0
  181. data/spec/multi_dependency_manager_spec.rb +25 -0
  182. data/spec/nodejs_deploy_spec.rb +30 -0
  183. data/spec/php_deploy_spec.rb +81 -0
  184. data/spec/platform_configure_spec.rb +61 -0
  185. data/spec/rails31_deploy_spec.rb +164 -0
  186. data/spec/restart_spec.rb +43 -0
  187. data/spec/rollback_spec.rb +87 -0
  188. data/spec/server_spec.rb +70 -0
  189. data/spec/services_deploy_spec.rb +153 -0
  190. data/spec/shell_spec.rb +57 -0
  191. data/spec/source/archive_spec.rb +33 -0
  192. data/spec/source/git_spec.rb +44 -0
  193. data/spec/spec_helper.rb +355 -0
  194. data/spec/sqlite3_deploy_spec.rb +38 -0
  195. data/spec/support/integration.rb +103 -0
  196. data/spec/support/source_doubles.rb +28 -0
  197. data/spec/support/timecop.rb +5 -0
  198. data/spec/symlink_spec.rb +15 -0
  199. metadata +522 -184
  200. data/lib/engineyard-serverside/callbacks.rb +0 -11
  201. data/lib/engineyard-serverside/callbacks/collection.rb +0 -17
  202. data/lib/engineyard-serverside/callbacks/collection/base.rb +0 -94
  203. data/lib/engineyard-serverside/callbacks/collection/combined.rb +0 -45
  204. data/lib/engineyard-serverside/callbacks/collection/deploy_hooks.rb +0 -21
  205. data/lib/engineyard-serverside/callbacks/collection/service_hooks.rb +0 -17
  206. data/lib/engineyard-serverside/callbacks/collection/service_hooks/collection.rb +0 -24
  207. data/lib/engineyard-serverside/callbacks/collection/service_hooks/combined.rb +0 -40
  208. data/lib/engineyard-serverside/callbacks/distributor.rb +0 -23
  209. data/lib/engineyard-serverside/callbacks/distributor/base.rb +0 -38
  210. data/lib/engineyard-serverside/callbacks/distributor/executable.rb +0 -19
  211. data/lib/engineyard-serverside/callbacks/distributor/executable/runnable.rb +0 -41
  212. data/lib/engineyard-serverside/callbacks/distributor/executable/unrunnable.rb +0 -19
  213. data/lib/engineyard-serverside/callbacks/distributor/ruby.rb +0 -59
  214. data/lib/engineyard-serverside/callbacks/distributor/ruby/distributor.rb +0 -57
  215. data/lib/engineyard-serverside/callbacks/hooks/app.rb +0 -17
  216. data/lib/engineyard-serverside/callbacks/hooks/base.rb +0 -39
  217. data/lib/engineyard-serverside/callbacks/hooks/service.rb +0 -24
  218. data/lib/engineyard-serverside/callbacks/service_hook.rb +0 -20
  219. data/lib/engineyard-serverside/cli/app.rb +0 -136
  220. data/lib/engineyard-serverside/cli/helpers.rb +0 -58
  221. data/lib/engineyard-serverside/cli/server_hash_extractor.rb +0 -49
  222. data/lib/engineyard-serverside/cli/workflows.rb +0 -45
  223. data/lib/engineyard-serverside/cli/workflows/base.rb +0 -78
  224. data/lib/engineyard-serverside/cli/workflows/calling_deploy_hooks.rb +0 -31
  225. data/lib/engineyard-serverside/cli/workflows/deploying_applications.rb +0 -28
  226. data/lib/engineyard-serverside/cli/workflows/disabling_maintenance.rb +0 -29
  227. data/lib/engineyard-serverside/cli/workflows/enabling_maintenance.rb +0 -29
  228. data/lib/engineyard-serverside/cli/workflows/errors.rb +0 -13
  229. data/lib/engineyard-serverside/cli/workflows/helpers.rb +0 -21
  230. data/lib/engineyard-serverside/cli/workflows/integrating_servers.rb +0 -71
  231. data/lib/engineyard-serverside/cli/workflows/restarting_applications.rb +0 -36
  232. data/lib/engineyard-serverside/cli/workflows/rolling_back_applications.rb +0 -28
  233. data/lib/engineyard-serverside/cli/workflows/showing_maintenance_status.rb +0 -28
  234. data/lib/engineyard-serverside/deploy_hook/callback_context.rb +0 -77
  235. data/lib/engineyard-serverside/propagator.rb +0 -59
  236. data/lib/engineyard-serverside/slug.rb +0 -7
  237. data/lib/engineyard-serverside/slug/distributor.rb +0 -58
  238. data/lib/engineyard-serverside/slug/enabler.rb +0 -100
  239. data/lib/engineyard-serverside/slug/failure_handler.rb +0 -24
  240. data/lib/engineyard-serverside/slug/finalizer.rb +0 -86
  241. data/lib/engineyard-serverside/slug/generator.rb +0 -29
  242. data/lib/engineyard-serverside/slug/migrator.rb +0 -41
  243. data/lib/engineyard-serverside/slug/restarter.rb +0 -103
  244. data/lib/engineyard-serverside/slug/source.rb +0 -16
  245. data/lib/engineyard-serverside/slug/source/updater.rb +0 -194
  246. data/lib/railway.rb +0 -43
  247. data/lib/result.rb +0 -7
  248. data/lib/result/base.rb +0 -41
  249. data/lib/result/dsl.rb +0 -16
  250. data/lib/result/failure.rb +0 -29
  251. data/lib/result/success.rb +0 -24
  252. data/lib/runner.rb +0 -34
@@ -8,4 +8,4 @@ $LOAD_PATH.push(File.expand_path("../lib", File.dirname(__FILE__)))
8
8
 
9
9
  require 'engineyard-serverside'
10
10
 
11
- EY::Serverside::CLI::App.start
11
+ EY::Serverside::CLI.start
@@ -25,16 +25,17 @@ module EY
25
25
  end
26
26
 
27
27
  def gem_binary
28
- gem_bin_path = File.join(Gem.default_bindir, 'gem')
29
- if File.exists?("/usr/local/ey_resin/bin/ruby")
30
- "/usr/local/ey_resin/bin/ruby -rubygems #{gem_bin_path}"
31
- else
32
- gem_bin_path
33
- end
28
+ File.join(Gem.default_bindir, 'gem')
34
29
  end
35
30
 
36
31
  def binary
37
- File.expand_path("../../../bin/#{gem_name}", __FILE__)
32
+ resin_path = "/usr/local/ey_resin/ruby/bin/engineyard-serverside"
33
+ if File.exists?(resin_path)
34
+ resin_path
35
+ else
36
+ #gem relative path causes deploy hook failures if gem version mismatches with other app servers
37
+ File.expand_path("../../../bin/#{gem_name}", __FILE__)
38
+ end
38
39
  end
39
40
 
40
41
  def hook_executor
@@ -1,11 +1,232 @@
1
- require 'engineyard-serverside/cli/app'
1
+ require 'thor'
2
+ require 'pathname'
3
+ require 'engineyard-serverside/about'
4
+ require 'engineyard-serverside/deploy'
5
+ require 'engineyard-serverside/shell'
6
+ require 'engineyard-serverside/servers'
7
+ require 'engineyard-serverside/cli_helpers'
2
8
 
3
9
  module EY
4
10
  module Serverside
11
+ class CLI < Thor
12
+
13
+ extend CLIHelpers
14
+
15
+ method_option :migrate, :type => :string,
16
+ :desc => "Run migrations with this deploy",
17
+ :aliases => ["-m"]
18
+
19
+ method_option :branch, :type => :string,
20
+ :desc => "Git ref to deploy, defaults to master. May be a branch, a tag, or a SHA",
21
+ :aliases => %w[-b --ref --tag]
22
+
23
+ method_option :repo, :type => :string,
24
+ :desc => "Remote repo to deploy",
25
+ :aliases => ["-r"]
26
+
27
+
28
+ # Archive source strategy
29
+ method_option :archive, :type => :string,
30
+ :desc => "Remote URI for archive to download and unzip"
31
+
32
+ # Git source strategy
33
+ method_option :git, :type => :string,
34
+ :desc => "Remote git repo to deploy"
35
+
36
+ method_option :clean, :type => :boolean,
37
+ :desc => "Run deploy without relying on existing files"
38
+
39
+
40
+ account_app_env_options
41
+ config_option
42
+ framework_env_option
43
+ instances_options
44
+ stack_option
45
+ verbose_option
46
+
47
+ desc "deploy", "Deploy code to /data/<app>"
48
+ def deploy(default_task=:deploy)
49
+ init_and_propagate(options, default_task.to_s) do |servers, config, shell|
50
+ EY::Serverside::Deploy.new(servers, config, shell).send(default_task)
51
+ end
52
+ end
53
+
54
+ account_app_env_options
55
+ config_option
56
+ instances_options
57
+ verbose_option
58
+ desc "enable_maintenance", "Enable maintenance page (disables web access)"
59
+ def enable_maintenance
60
+ init_and_propagate(options, 'enable_maintenance') do |servers, config, shell|
61
+ EY::Serverside::Maintenance.new(servers, config, shell).manually_enable
62
+ end
63
+ end
64
+
65
+ account_app_env_options
66
+ config_option
67
+ instances_options
68
+ verbose_option
69
+ desc "maintenance_status", "Maintenance status"
70
+ def maintenance_status
71
+ init(options, "maintenance-status") do |servers, config, shell|
72
+ EY::Serverside::Maintenance.new(servers, config, shell).status
73
+ end
74
+ end
75
+
76
+ account_app_env_options
77
+ config_option
78
+ instances_options
79
+ verbose_option
80
+ desc "disable_maintenance", "Disable maintenance page (enables web access)"
81
+ def disable_maintenance
82
+ init_and_propagate(options, 'disable_maintenance') do |servers, config, shell|
83
+ EY::Serverside::Maintenance.new(servers, config, shell).manually_disable
84
+ end
85
+ end
86
+
87
+ method_option :release_path, :type => :string,
88
+ :desc => "Value for #release_path in hooks (mostly for internal coordination)",
89
+ :aliases => ["-r"]
90
+
91
+ method_option :current_roles, :type => :array,
92
+ :desc => "Value for #current_roles in hooks"
93
+
94
+ method_option :current_name, :type => :string,
95
+ :desc => "Value for #current_name in hooks"
96
+ account_app_env_options
97
+ config_option
98
+ framework_env_option
99
+ verbose_option
100
+ desc "hook [NAME]", "Run a particular deploy hook"
101
+ def hook(hook_name)
102
+ init(options, "hook-#{hook_name}") do |servers, config, shell|
103
+ EY::Serverside::DeployHook.new(config, shell, hook_name).call
104
+ end
105
+ end
106
+
107
+ method_option :ignore_existing, :type => :boolean,
108
+ :desc => "When syncing /data/app directory, don't overwrite destination files"
109
+ account_app_env_options
110
+ config_option
111
+ framework_env_option
112
+ instances_options
113
+ stack_option
114
+ verbose_option
115
+ desc "integrate", "Integrate other instances into this cluster"
116
+ def integrate
117
+ app_dir = Pathname.new "/data/#{options[:app]}"
118
+ current_app_dir = app_dir.join("current")
119
+
120
+ # so that we deploy to the same place there that we have here
121
+ integrate_options = options.dup
122
+ integrate_options[:release_path] = current_app_dir.realpath.to_s
123
+
124
+ # we have to deploy the same SHA there as here
125
+ integrate_options[:branch] = current_app_dir.join('REVISION').read.strip
126
+
127
+ # always rebundle gems on integrate to make sure the instance comes up correctly.
128
+ integrate_options[:clean] = true
129
+
130
+ logname = "integrate-#{options[:instances].join('-')}".gsub(/[^-.\w]/,'')
131
+
132
+ init_and_propagate(integrate_options, logname) do |servers, config, shell|
133
+
134
+ # We have to rsync the entire app dir, so we need all the permissions to be correct!
135
+ chown_command = %|find #{app_dir} \\( -not -user #{config.user} -or -not -group #{config.group} \\) -exec chown -h #{config.user}:#{config.group} "{}" +|
136
+ shell.logged_system("sudo sh -l -c '#{chown_command}'", servers.detect {|s| s.local?})
137
+
138
+ servers.run_for_each! do |server|
139
+ chown = server.command_on_server('sudo sh -l -c', chown_command)
140
+ sync = server.sync_directory_command(app_dir, options[:ignore_existing])
141
+ clean = server.command_on_server('sh -l -c', "rm -rf #{current_app_dir}")
142
+ "(#{chown}) && (#{sync}) && (#{clean})"
143
+ end
144
+
145
+ # deploy local-ref to other instances into /data/$app/local-current
146
+ EY::Serverside::Deploy.new(servers, config, shell).cached_deploy
147
+ end
148
+ end
149
+
150
+ account_app_env_options
151
+ instances_options
152
+ stack_option
153
+ verbose_option
154
+ desc "restart", "Restart app servers, conditionally enabling maintenance page"
155
+ def restart
156
+ options = self.options.dup
157
+ options[:release_path] = Pathname.new("/data/#{options[:app]}/current").realpath.to_s
158
+
159
+ init_and_propagate(options, 'restart') do |servers, config, shell|
160
+ EY::Serverside::Deploy.new(servers, config, shell).restart_with_maintenance_page
161
+ end
162
+ end
163
+
164
+ private
165
+
166
+ def init_and_propagate(*args)
167
+ init(*args) do |servers, config, shell|
168
+ propagate(servers, shell)
169
+ yield servers, config, shell
170
+ end
171
+ end
172
+
173
+ def init(options, action)
174
+ config = EY::Serverside::Deploy::Configuration.new(options)
175
+ shell = EY::Serverside::Shell.new(
176
+ :verbose => config.verbose,
177
+ :log_path => File.join(ENV['HOME'], "#{config.app}-#{action}.log")
178
+ )
179
+ shell.debug "Initializing #{About.name_with_version}."
180
+ servers = load_servers(config, shell)
181
+ begin
182
+ yield servers, config, shell
183
+ rescue EY::Serverside::RemoteFailure => e
184
+ shell.fatal e.message
185
+ raise
186
+ rescue Exception => e
187
+ shell.fatal "#{e.backtrace[0]}: #{e.message} (#{e.class})"
188
+ raise
189
+ end
190
+ end
191
+
192
+ def propagate(servers, shell)
193
+ shell.status "Verifying and propagating #{About.name_with_version} to all servers."
194
+
195
+ gem_binary = File.join(Gem.default_bindir, 'gem')
196
+ remote_gem_file = File.join(Dir.tmpdir, About.gem_filename)
197
+
198
+ # the [,)] is to stop us from looking for e.g. 0.5.1, seeing
199
+ # 0.5.11, and mistakenly thinking 0.5.1 is there
200
+ check_command = %{#{gem_binary} list #{About.gem_name} | grep "#{About.gem_name}" | egrep -q "#{About.version.gsub(/\./, '\.')}[,)]"}
201
+ install_command = "#{gem_binary} install --no-rdoc --no-ri '#{remote_gem_file}'"
202
+
203
+ servers.remote.run_for_each! do |server|
204
+ check = server.command_on_server('sh -l -c', check_command)
205
+ scp = server.scp_command(About.gem_file, remote_gem_file)
206
+ install = server.command_on_server('sudo sh -l -c', install_command)
207
+
208
+ "(#{check}) || ((#{scp}) && (#{install}))"
209
+ end
210
+ end
211
+
212
+ def load_servers(config, shell)
213
+ EY::Serverside::Servers.from_hashes(assemble_instance_hashes(config), shell)
214
+ end
215
+
216
+ def assemble_instance_hashes(config)
217
+ if options[:instances]
218
+ options[:instances].collect { |hostname|
219
+ { :hostname => hostname,
220
+ :roles => options[:instance_roles][hostname].to_s.split(','),
221
+ :name => options[:instance_names][hostname],
222
+ :user => config.user,
223
+ }
224
+ }
225
+ else
226
+ []
227
+ end
228
+ end
5
229
 
6
- # CLI is a namespace that encompasses all concepts around command-line
7
- # interactions with EY::Serverside
8
- module CLI
9
230
  end
10
231
  end
11
232
  end
@@ -0,0 +1,53 @@
1
+ module EY
2
+ module Serverside
3
+ module CLIHelpers
4
+ def account_app_env_options
5
+ method_option :app, :type => :string,
6
+ :required => true,
7
+ :desc => "Application to deploy",
8
+ :aliases => %w[-a --app-name]
9
+ method_option :environment_name, :type => :string,
10
+ :required => true,
11
+ :desc => "Environment name"
12
+ method_option :account_name, :type => :string,
13
+ :required => true,
14
+ :desc => "Account name"
15
+ end
16
+
17
+ def framework_env_option
18
+ method_option :framework_env, :type => :string,
19
+ :required => true,
20
+ :desc => "Ruby web framework environment",
21
+ :aliases => ["-e"]
22
+ end
23
+
24
+ def stack_option
25
+ method_option :stack, :type => :string,
26
+ :desc => "Web stack (so we can restart it correctly)"
27
+ end
28
+
29
+
30
+ def config_option
31
+ method_option :config, :type => :string,
32
+ :desc => "Additional configuration"
33
+ end
34
+
35
+ def instances_options
36
+ method_option :instances, :type => :array,
37
+ :desc => "Hostnames of instances to deploy to, e.g. --instances localhost app1 app2"
38
+ method_option :instance_roles, :type => :hash,
39
+ :default => {},
40
+ :desc => "Roles of instances, keyed on hostname, comma-separated. e.g. instance1:app_master,etc instance2:db,memcached ..."
41
+ method_option :instance_names, :type => :hash,
42
+ :default => {},
43
+ :desc => "Instance names, keyed on hostname. e.g. instance1:name1 instance2:name2"
44
+ end
45
+
46
+ def verbose_option
47
+ method_option :verbose, :type => :boolean,
48
+ :desc => "Verbose output",
49
+ :aliases => ["-v"]
50
+ end
51
+ end
52
+ end
53
+ end
@@ -101,7 +101,6 @@ module EY
101
101
  def_option(:group) { user }
102
102
  def_option :services_check_command, "which /usr/local/ey_resin/ruby/bin/ey-services-setup >/dev/null 2>&1"
103
103
  def_option(:services_setup_command) { "/usr/local/ey_resin/ruby/bin/ey-services-setup #{app}" }
104
- def_option :ignore_ey_config_warning, false
105
104
 
106
105
  DEFAULT_KEEP_RELEASES = 3
107
106
 
@@ -4,19 +4,12 @@ module EY
4
4
  module Serverside
5
5
  class DependencyManager
6
6
  class Bundler < Base
7
- DEFAULT_VERSION = "1.14.6"
8
-
9
- # Number of Bundler workers (--jobs)
10
- JOBS_NUMBER = 4
7
+ DEFAULT_VERSION = "1.7.9"
11
8
 
12
9
  def self.default_version
13
10
  DEFAULT_VERSION
14
11
  end
15
12
 
16
- def self.jobs_number
17
- JOBS_NUMBER
18
- end
19
-
20
13
  def detected?
21
14
  gemfile?
22
15
  end
@@ -66,7 +59,7 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
66
59
  end
67
60
 
68
61
  def show_ey_config_instructions
69
- if lockfile && !lockfile.has_ey_config? && !config.ignore_ey_config_warning
62
+ if lockfile && !lockfile.has_ey_config?
70
63
  shell.warning "Gemfile.lock does not contain ey_config. Add gem 'ey_config' to your Gemfile to access service configurations through EY::Config."
71
64
  end
72
65
  end
@@ -94,7 +87,7 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
94
87
  # the [,)] is to stop us from looking for e.g. 0.9.2, seeing
95
88
  # 0.9.22, and mistakenly thinking 0.9.2 is there
96
89
  has_gem_cmd = %{gem list bundler | grep "bundler " | egrep -q "#{egrep_escaped_version}[,)]"}
97
- install_cmd = %{gem install bundler -q -v "#{bundler_version}"}
90
+ install_cmd = %{gem install bundler -q --no-rdoc --no-ri -v "#{bundler_version}"}
98
91
  sudo "#{clean_environment} && #{has_gem_cmd} || #{install_cmd}"
99
92
  end
100
93
 
@@ -110,11 +103,6 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
110
103
  "--path", "#{paths.bundled_gems}",
111
104
  "--binstubs", "#{paths.binstubs}",
112
105
  ]
113
-
114
- # Install gems in parallel (Bundler.1.5+ only)
115
- # @see EYPP-58
116
- options += ["--jobs", self.class.jobs_number] if check_version(bundler_version, ">= 1.5")
117
-
118
106
  options += ["--deployment"] if lockfile
119
107
  options += config.extra_bundle_install_options
120
108
  options
@@ -132,9 +120,10 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
132
120
  shell.substatus "Clean bundle forced (--clean)"
133
121
  run clean_bundle
134
122
  else
123
+ check_ruby = "#{config.ruby_version_command} | diff - #{paths.ruby_version} >/dev/null 2>&1"
135
124
  check_system = "#{config.system_version_command} | diff - #{paths.system_version} >/dev/null 2>&1"
136
125
  shell.substatus "Checking for system version changes"
137
- run "#{check_system} || #{clean_bundle}"
126
+ run "#{check_ruby} && #{check_system} || #{clean_bundle}"
138
127
  end
139
128
  end
140
129
 
@@ -151,24 +140,9 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
151
140
  end
152
141
  end
153
142
 
154
- ##
155
- # Checks that given version is satisfies give requirement.
156
- #
157
- # @param [String] version
158
- # @param [String] requirement
159
- # @return [true, false]
160
- #
161
- def check_version(version, requirement)
162
- Gem::Requirement.new( requirement ).satisfied_by? Gem::Version.new( version )
163
- end
164
-
165
143
  class Lockfile
166
144
  attr_reader :bundler_version
167
145
 
168
- METADATA = 'METADATA'.freeze
169
- BUNDLED = 'BUNDLED WITH'.freeze
170
- DEPENDENCIES = 'DEPENDENCIES'.freeze
171
-
172
146
  def initialize(lockfile_contents, default = EY::Serverside::DependencyManager::Bundler.default_version)
173
147
  @contents = lockfile_contents
174
148
  @default = default
@@ -206,8 +180,9 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
206
180
  end
207
181
 
208
182
  def parse
209
- @bundler_version = parse_from_metadata || parse_from_bundled_with || parse_from_dependencies
210
- raise("Malformed or pre bundler-1.0.0 Gemfile.lock: #{@contents[0,50]}...") unless @bundler_version
183
+ parse_from_metadata ||
184
+ parse_from_dependencies ||
185
+ raise("Malformed or pre bundler-1.0.0 Gemfile.lock: #{@contents[0,50]}...")
211
186
  end
212
187
 
213
188
  def slice_section(header)
@@ -220,28 +195,25 @@ To fix this problem, commit your Gemfile.lock to your repository and redeploy.
220
195
  end
221
196
 
222
197
  def parse_from_metadata
223
- section = slice_section(METADATA)
224
- return if section.empty?
225
-
226
- result = section.scan(/^\s*version:\s*(.*)$/).first
227
- result ? result.first : @default
228
- end
198
+ section = slice_section('METADATA')
229
199
 
230
- def parse_from_bundled_with
231
- section = slice_section(BUNDLED)
232
- return if section.empty?
200
+ if section.empty?
201
+ return nil
202
+ end
233
203
 
234
- result = section.scan(/^#{BUNDLED}\s*(.*)$/).first
235
- result ? result.first : @default
204
+ result = section.scan(/^\s*version:\s*(.*)$/).first
205
+ @bundler_version = result ? result.first : @default
236
206
  end
237
207
 
238
208
  def dependencies_section
239
- @dependencies_section ||= slice_section(DEPENDENCIES)
209
+ @dependencies_section ||= slice_section('DEPENDENCIES')
240
210
  end
241
211
 
242
212
  def parse_from_dependencies
243
213
  section = dependencies_section
244
- return if section.empty?
214
+ if section.empty?
215
+ return nil
216
+ end
245
217
 
246
218
  result = scan_gem('bundler', section)
247
219
  bundler_version = result ? result.last : nil