engineyard-serverside 2.6.14 → 2.6.15.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +13 -5
  2. data/bin/engineyard-serverside +1 -1
  3. data/lib/engineyard-serverside/cli.rb +4 -225
  4. data/lib/engineyard-serverside/cli/app.rb +136 -0
  5. data/lib/engineyard-serverside/cli/helpers.rb +58 -0
  6. data/lib/engineyard-serverside/cli/server_hash_extractor.rb +49 -0
  7. data/lib/engineyard-serverside/cli/workflows.rb +45 -0
  8. data/lib/engineyard-serverside/cli/workflows/base.rb +78 -0
  9. data/lib/engineyard-serverside/cli/workflows/calling_deploy_hooks.rb +31 -0
  10. data/lib/engineyard-serverside/cli/workflows/deploying_applications.rb +28 -0
  11. data/lib/engineyard-serverside/cli/workflows/disabling_maintenance.rb +29 -0
  12. data/lib/engineyard-serverside/cli/workflows/enabling_maintenance.rb +29 -0
  13. data/lib/engineyard-serverside/cli/workflows/errors.rb +13 -0
  14. data/lib/engineyard-serverside/cli/workflows/helpers.rb +21 -0
  15. data/lib/engineyard-serverside/cli/workflows/integrating_servers.rb +63 -0
  16. data/lib/engineyard-serverside/cli/workflows/restarting_applications.rb +36 -0
  17. data/lib/engineyard-serverside/cli/workflows/rolling_back_applications.rb +28 -0
  18. data/lib/engineyard-serverside/cli/workflows/showing_maintenance_status.rb +28 -0
  19. data/lib/engineyard-serverside/dependency_manager/bundler.rb +43 -14
  20. data/lib/engineyard-serverside/propagator.rb +59 -0
  21. data/lib/engineyard-serverside/rails_assets.rb +5 -2
  22. data/lib/engineyard-serverside/version.rb +1 -1
  23. metadata +66 -394
  24. data/lib/engineyard-serverside/cli_helpers.rb +0 -53
  25. data/spec/archive_deploy_spec.rb +0 -53
  26. data/spec/basic_deploy_spec.rb +0 -26
  27. data/spec/bundler_deploy_spec.rb +0 -139
  28. data/spec/configuration_spec.rb +0 -205
  29. data/spec/custom_deploy_spec.rb +0 -128
  30. data/spec/deploy_hook_spec.rb +0 -362
  31. data/spec/deprecation_spec.rb +0 -23
  32. data/spec/ey_yml_customized_deploy_spec.rb +0 -99
  33. data/spec/fixtures/gitrepo.tar.gz +0 -0
  34. data/spec/fixtures/gitrepo/bar +0 -0
  35. data/spec/fixtures/gitrepo/foo +0 -0
  36. data/spec/fixtures/invalid_hook.rb +0 -1
  37. data/spec/fixtures/lockfiles/0.9-no-bundler +0 -111
  38. data/spec/fixtures/lockfiles/0.9-with-bundler +0 -117
  39. data/spec/fixtures/lockfiles/1.0-no-bundler +0 -54
  40. data/spec/fixtures/lockfiles/1.0.0.rc.1-with-bundler +0 -162
  41. data/spec/fixtures/lockfiles/1.0.18-do_mysql +0 -88
  42. data/spec/fixtures/lockfiles/1.0.18-do_postgres +0 -79
  43. data/spec/fixtures/lockfiles/1.0.18-mysql +0 -43
  44. data/spec/fixtures/lockfiles/1.0.18-mysql2 +0 -43
  45. data/spec/fixtures/lockfiles/1.0.18-pg +0 -43
  46. data/spec/fixtures/lockfiles/1.0.6-no-bundler +0 -51
  47. data/spec/fixtures/lockfiles/1.0.6-with-any-bundler +0 -52
  48. data/spec/fixtures/lockfiles/1.0.6-with-bundler +0 -52
  49. data/spec/fixtures/lockfiles/1.3.1-rails-3.2.13 +0 -112
  50. data/spec/fixtures/lockfiles/not-a-lockfile +0 -1
  51. data/spec/fixtures/repos/assets_detected/Gemfile +0 -5
  52. data/spec/fixtures/repos/assets_detected/Gemfile.lock +0 -88
  53. data/spec/fixtures/repos/assets_detected/README +0 -1
  54. data/spec/fixtures/repos/assets_detected/Rakefile +0 -5
  55. data/spec/fixtures/repos/assets_detected/app/assets/empty +0 -0
  56. data/spec/fixtures/repos/assets_detected/config/application.rb +0 -5
  57. data/spec/fixtures/repos/assets_detected/config/ey.yml +0 -3
  58. data/spec/fixtures/repos/assets_disabled/Gemfile +0 -5
  59. data/spec/fixtures/repos/assets_disabled/Gemfile.lock +0 -88
  60. data/spec/fixtures/repos/assets_disabled/README +0 -1
  61. data/spec/fixtures/repos/assets_disabled/Rakefile +0 -6
  62. data/spec/fixtures/repos/assets_disabled/app/assets/empty +0 -0
  63. data/spec/fixtures/repos/assets_disabled/config/application.rb +0 -5
  64. data/spec/fixtures/repos/assets_disabled/config/ey.yml +0 -3
  65. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile +0 -5
  66. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Gemfile.lock +0 -88
  67. data/spec/fixtures/repos/assets_disabled_in_ey_yml/README +0 -1
  68. data/spec/fixtures/repos/assets_disabled_in_ey_yml/Rakefile +0 -6
  69. data/spec/fixtures/repos/assets_disabled_in_ey_yml/app/assets/empty +0 -0
  70. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/application.rb +0 -5
  71. data/spec/fixtures/repos/assets_disabled_in_ey_yml/config/ey.yml +0 -5
  72. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile +0 -5
  73. data/spec/fixtures/repos/assets_disabled_utf8/Gemfile.lock +0 -88
  74. data/spec/fixtures/repos/assets_disabled_utf8/README +0 -3
  75. data/spec/fixtures/repos/assets_disabled_utf8/Rakefile +0 -5
  76. data/spec/fixtures/repos/assets_disabled_utf8/app/assets/empty +0 -0
  77. data/spec/fixtures/repos/assets_disabled_utf8/config/application.rb +0 -7
  78. data/spec/fixtures/repos/assets_disabled_utf8/config/ey.yml +0 -3
  79. data/spec/fixtures/repos/assets_enabled_all/Gemfile +0 -5
  80. data/spec/fixtures/repos/assets_enabled_all/Gemfile.lock +0 -88
  81. data/spec/fixtures/repos/assets_enabled_all/README +0 -1
  82. data/spec/fixtures/repos/assets_enabled_all/app/assets/empty +0 -0
  83. data/spec/fixtures/repos/assets_enabled_all/config/application.rb +0 -5
  84. data/spec/fixtures/repos/assets_enabled_all/config/ey.yml +0 -6
  85. data/spec/fixtures/repos/assets_enabled_all/script/assets +0 -5
  86. data/spec/fixtures/repos/assets_enabled_all/tmp/obstruction +0 -1
  87. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile +0 -3
  88. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Gemfile.lock +0 -10
  89. data/spec/fixtures/repos/assets_enabled_in_ey_yml/README +0 -1
  90. data/spec/fixtures/repos/assets_enabled_in_ey_yml/Rakefile +0 -8
  91. data/spec/fixtures/repos/assets_enabled_in_ey_yml/config/ey.yml +0 -4
  92. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile +0 -5
  93. data/spec/fixtures/repos/assets_enabled_util_only/Gemfile.lock +0 -88
  94. data/spec/fixtures/repos/assets_enabled_util_only/README +0 -1
  95. data/spec/fixtures/repos/assets_enabled_util_only/Rakefile +0 -6
  96. data/spec/fixtures/repos/assets_enabled_util_only/app/assets/empty +0 -0
  97. data/spec/fixtures/repos/assets_enabled_util_only/config/application.rb +0 -5
  98. data/spec/fixtures/repos/assets_enabled_util_only/config/ey.yml +0 -6
  99. data/spec/fixtures/repos/assets_in_hook/Gemfile +0 -5
  100. data/spec/fixtures/repos/assets_in_hook/Gemfile.lock +0 -88
  101. data/spec/fixtures/repos/assets_in_hook/README +0 -2
  102. data/spec/fixtures/repos/assets_in_hook/Rakefile +0 -5
  103. data/spec/fixtures/repos/assets_in_hook/app/assets/empty +0 -0
  104. data/spec/fixtures/repos/assets_in_hook/config/application.rb +0 -5
  105. data/spec/fixtures/repos/assets_in_hook/config/ey.yml +0 -3
  106. data/spec/fixtures/repos/assets_in_hook/deploy/before_compile_assets.rb +0 -2
  107. data/spec/fixtures/repos/bundle_fails/Gemfile +0 -1
  108. data/spec/fixtures/repos/bundle_fails/README +0 -1
  109. data/spec/fixtures/repos/bundle_fails/deploy/after_bundle.rb +0 -1
  110. data/spec/fixtures/repos/bundler_disabled/Gemfile +0 -4
  111. data/spec/fixtures/repos/bundler_disabled/Gemfile.lock +0 -12
  112. data/spec/fixtures/repos/bundler_disabled/README +0 -1
  113. data/spec/fixtures/repos/bundler_disabled/config/ey.yml +0 -2
  114. data/spec/fixtures/repos/bundler_disabled/deploy/after_bundle.rb +0 -1
  115. data/spec/fixtures/repos/bundler_disabled/deploy/before_bundle.rb +0 -1
  116. data/spec/fixtures/repos/default/Gemfile +0 -4
  117. data/spec/fixtures/repos/default/Gemfile.lock +0 -12
  118. data/spec/fixtures/repos/default/README +0 -5
  119. data/spec/fixtures/repos/default/ey.yml +0 -3
  120. data/spec/fixtures/repos/executable_hooks/README +0 -1
  121. data/spec/fixtures/repos/executable_hooks/deploy/before_restart +0 -72
  122. data/spec/fixtures/repos/executable_hooks_not_executable/README +0 -3
  123. data/spec/fixtures/repos/executable_hooks_not_executable/deploy/before_restart +0 -3
  124. data/spec/fixtures/repos/ey_yml/Gemfile +0 -4
  125. data/spec/fixtures/repos/ey_yml/Gemfile.lock +0 -12
  126. data/spec/fixtures/repos/ey_yml/README +0 -1
  127. data/spec/fixtures/repos/ey_yml/config/ey.yml +0 -18
  128. data/spec/fixtures/repos/ey_yml/deploy/before_migrate.rb +0 -6
  129. data/spec/fixtures/repos/ey_yml_alt/Gemfile +0 -4
  130. data/spec/fixtures/repos/ey_yml_alt/Gemfile.lock +0 -12
  131. data/spec/fixtures/repos/ey_yml_alt/README +0 -1
  132. data/spec/fixtures/repos/ey_yml_alt/deploy/before_migrate.rb +0 -6
  133. data/spec/fixtures/repos/ey_yml_alt/ey.yml +0 -12
  134. data/spec/fixtures/repos/hook_fails/README +0 -1
  135. data/spec/fixtures/repos/hook_fails/deploy/before_deploy.rb +0 -1
  136. data/spec/fixtures/repos/hooks/README +0 -1
  137. data/spec/fixtures/repos/hooks/deploy/after_bundle.rb +0 -1
  138. data/spec/fixtures/repos/hooks/deploy/after_compile_assets.rb +0 -1
  139. data/spec/fixtures/repos/hooks/deploy/after_deploy.rb +0 -1
  140. data/spec/fixtures/repos/hooks/deploy/after_migrate.rb +0 -1
  141. data/spec/fixtures/repos/hooks/deploy/after_restart.rb +0 -1
  142. data/spec/fixtures/repos/hooks/deploy/after_symlink.rb +0 -1
  143. data/spec/fixtures/repos/hooks/deploy/before_bundle.rb +0 -1
  144. data/spec/fixtures/repos/hooks/deploy/before_compile_assets.rb +0 -1
  145. data/spec/fixtures/repos/hooks/deploy/before_deploy.rb +0 -1
  146. data/spec/fixtures/repos/hooks/deploy/before_migrate.rb +0 -1
  147. data/spec/fixtures/repos/hooks/deploy/before_restart.rb +0 -1
  148. data/spec/fixtures/repos/hooks/deploy/before_symlink.rb +0 -1
  149. data/spec/fixtures/repos/multi_dep_manager/README +0 -1
  150. data/spec/fixtures/repos/multi_dep_manager/composer.json +0 -5
  151. data/spec/fixtures/repos/multi_dep_manager/composer.lock +0 -462
  152. data/spec/fixtures/repos/multi_dep_manager/package.json +0 -7
  153. data/spec/fixtures/repos/multi_dep_manager/public/index.php +0 -4
  154. data/spec/fixtures/repos/no_ey_config/Gemfile +0 -3
  155. data/spec/fixtures/repos/no_ey_config/Gemfile.lock +0 -10
  156. data/spec/fixtures/repos/no_ey_config/README +0 -1
  157. data/spec/fixtures/repos/no_ey_config/ey.yml +0 -3
  158. data/spec/fixtures/repos/no_gemfile_lock/Gemfile +0 -4
  159. data/spec/fixtures/repos/no_gemfile_lock/README +0 -1
  160. data/spec/fixtures/repos/no_gemfile_lock/ey.yml +0 -3
  161. data/spec/fixtures/repos/nodejs/README +0 -1
  162. data/spec/fixtures/repos/nodejs/package.json +0 -7
  163. data/spec/fixtures/repos/not_bundled/README +0 -1
  164. data/spec/fixtures/repos/npm_disabled/README +0 -1
  165. data/spec/fixtures/repos/npm_disabled/config/ey.yml +0 -2
  166. data/spec/fixtures/repos/npm_disabled/package.json +0 -7
  167. data/spec/fixtures/repos/php_composer_disabled/README +0 -1
  168. data/spec/fixtures/repos/php_composer_disabled/composer.json +0 -5
  169. data/spec/fixtures/repos/php_composer_disabled/composer.lock +0 -462
  170. data/spec/fixtures/repos/php_composer_disabled/config/ey.yml +0 -2
  171. data/spec/fixtures/repos/php_composer_disabled/public/index.php +0 -4
  172. data/spec/fixtures/repos/php_composer_lock/README +0 -1
  173. data/spec/fixtures/repos/php_composer_lock/composer.json +0 -5
  174. data/spec/fixtures/repos/php_composer_lock/composer.lock +0 -462
  175. data/spec/fixtures/repos/php_composer_lock/public/index.php +0 -4
  176. data/spec/fixtures/repos/php_no_composer_lock/README +0 -1
  177. data/spec/fixtures/repos/php_no_composer_lock/composer.json +0 -21
  178. data/spec/fixtures/repos/php_no_composer_lock/public/index.php +0 -4
  179. data/spec/fixtures/repos/public_system/Gemfile +0 -4
  180. data/spec/fixtures/repos/public_system/Gemfile.lock +0 -12
  181. data/spec/fixtures/repos/public_system/README +0 -5
  182. data/spec/fixtures/repos/public_system/ey.yml +0 -3
  183. data/spec/fixtures/repos/public_system/public/system/cant_touch_this.txt +0 -3
  184. data/spec/fixtures/repos/sqlite3/Gemfile +0 -4
  185. data/spec/fixtures/repos/sqlite3/Gemfile.lock +0 -89
  186. data/spec/fixtures/repos/sqlite3/README +0 -1
  187. data/spec/fixtures/retwisj.war +0 -0
  188. data/spec/fixtures/valid_hook.rb +0 -1
  189. data/spec/git_strategy_spec.rb +0 -34
  190. data/spec/lockfile_parser_spec.rb +0 -122
  191. data/spec/maintenance_spec.rb +0 -44
  192. data/spec/multi_dependency_manager_spec.rb +0 -25
  193. data/spec/nodejs_deploy_spec.rb +0 -30
  194. data/spec/php_deploy_spec.rb +0 -81
  195. data/spec/platform_configure_spec.rb +0 -61
  196. data/spec/rails31_deploy_spec.rb +0 -164
  197. data/spec/restart_spec.rb +0 -43
  198. data/spec/rollback_spec.rb +0 -87
  199. data/spec/server_spec.rb +0 -70
  200. data/spec/services_deploy_spec.rb +0 -153
  201. data/spec/shell_spec.rb +0 -57
  202. data/spec/source/archive_spec.rb +0 -33
  203. data/spec/source/git_spec.rb +0 -44
  204. data/spec/spec_helper.rb +0 -355
  205. data/spec/sqlite3_deploy_spec.rb +0 -38
  206. data/spec/support/integration.rb +0 -103
  207. data/spec/support/source_doubles.rb +0 -28
  208. data/spec/support/timecop.rb +0 -5
  209. data/spec/symlink_spec.rb +0 -15
@@ -0,0 +1,49 @@
1
+ module EY
2
+ module Serverside
3
+ module CLI
4
+
5
+ # ServerHashExtractor, given an options hash and a deploy configuration,
6
+ # generates an array of hashes that can be used to instantiate Server
7
+ # objects
8
+ class ServerHashExtractor
9
+ def self.hashes(options, config)
10
+ new(options, config).hashes
11
+ end
12
+
13
+ attr_reader :options, :config
14
+
15
+ def initialize(options, config)
16
+ @options = options
17
+ @config = config
18
+ end
19
+
20
+ def hashes
21
+ return [] unless instances
22
+
23
+ instances.collect {|hostname|
24
+ {
25
+ :hostname => hostname,
26
+ :roles => instance_roles[hostname].to_s.split(','),
27
+ :name => instance_names[hostname],
28
+ :user => config.user
29
+ }
30
+ }
31
+ end
32
+
33
+ private
34
+ def instances
35
+ options[:instances]
36
+ end
37
+
38
+ def instance_roles
39
+ options[:instance_roles]
40
+ end
41
+
42
+ def instance_names
43
+ options[:instance_names]
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,45 @@
1
+ require 'engineyard-serverside/cli/workflows/calling_deploy_hooks'
2
+ require 'engineyard-serverside/cli/workflows/deploying_applications'
3
+ require 'engineyard-serverside/cli/workflows/disabling_maintenance'
4
+ require 'engineyard-serverside/cli/workflows/enabling_maintenance'
5
+ require 'engineyard-serverside/cli/workflows/integrating_servers'
6
+ require 'engineyard-serverside/cli/workflows/restarting_applications'
7
+ require 'engineyard-serverside/cli/workflows/rolling_back_applications'
8
+ require 'engineyard-serverside/cli/workflows/showing_maintenance_status'
9
+
10
+ module EY
11
+ module Serverside
12
+ module CLI
13
+
14
+ # Workflows is a collection of reified procedures that handle the
15
+ # various requirements of our CLI app
16
+ module Workflows
17
+ DEFINED = {
18
+ :deploy => DeployingApplications,
19
+ :disable_maintenance => DisablingMaintenance,
20
+ :enable_maintenance => EnablingMaintenance,
21
+ :hook => CallingDeployHooks,
22
+ :integrate => IntegratingServers,
23
+ :maintenance_status => ShowingMaintenanceStatus,
24
+ :restart => RestartingApplications,
25
+ :rollback => RollingBackApplications
26
+ }
27
+
28
+ def self.perform(workflow, options = {})
29
+ resolve(workflow).
30
+ perform(options)
31
+ end
32
+
33
+ def self.resolve(workflow)
34
+ (DEFINED[normalized(workflow)] || Base)
35
+ end
36
+
37
+ def self.normalized(workflow)
38
+ return nil if workflow.nil?
39
+
40
+ workflow.to_sym
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,78 @@
1
+ require 'engineyard-serverside/about'
2
+ require 'engineyard-serverside/cli/server_hash_extractor'
3
+ require 'engineyard-serverside/cli/workflows/errors'
4
+ require 'engineyard-serverside/configuration'
5
+
6
+ module EY
7
+ module Serverside
8
+ module CLI
9
+ module Workflows
10
+
11
+ # Base is the template from which all Workflows are derived
12
+ class Base
13
+ attr_reader :options
14
+
15
+ def initialize(options = {})
16
+ @options = options
17
+ end
18
+
19
+ def perform
20
+ shell.debug "Initializing #{About.name_with_version}."
21
+
22
+ begin
23
+ procedure
24
+ rescue EY::Serverside::RemoteFailure => remote_error
25
+ shell.fatal(remote_error.message)
26
+ raise
27
+ rescue Exception => error
28
+ shell.fatal("#{error.backtrace[0]}: #{error.message} (#{error.class})")
29
+ raise
30
+ end
31
+ end
32
+
33
+ def self.perform(options = {})
34
+ new(options).perform
35
+ end
36
+
37
+ private
38
+ def config
39
+ @config ||= EY::Serverside::Deploy::Configuration.new(options)
40
+ end
41
+
42
+ def shell
43
+ @shell ||= EY::Serverside::Shell.new(
44
+ :verbose => config.verbose,
45
+ :log_path => File.join(
46
+ ENV['HOME'],
47
+ "#{config.app}-#{task_name}.log"
48
+ )
49
+ )
50
+ end
51
+
52
+ def servers
53
+ @servers ||= EY::Serverside::Servers.from_hashes(
54
+ EY::Serverside::CLI::ServerHashExtractor.hashes(options, config),
55
+ shell
56
+ )
57
+ end
58
+
59
+ def task_name
60
+ raise Undefined.new(
61
+ "You must define the private task_name method for your workflow."
62
+ )
63
+ end
64
+
65
+ def procedure
66
+ raise Undefined.new(
67
+ "You must define the private procedure method for your workflow."
68
+ )
69
+ end
70
+
71
+ def propagate_serverside
72
+ EY::Serverside::Propagator.propagate(servers, shell)
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,31 @@
1
+ require 'engineyard-serverside/cli/workflows/base'
2
+ require 'engineyard-serverside/deploy_hook'
3
+
4
+ module EY
5
+ module Serverside
6
+ module CLI
7
+ module Workflows
8
+
9
+ # CallingDeployHooks is a Workflow that, given a hook_name option,
10
+ # executes the requested deploy hook
11
+ class CallingDeployHooks < Base
12
+ private
13
+ def procedure
14
+ EY::Serverside::DeployHook.
15
+ new(config, shell, hook_name).
16
+ call
17
+
18
+ end
19
+
20
+ def task_name
21
+ "hook-#{hook_name}"
22
+ end
23
+
24
+ def hook_name
25
+ options[:hook_name]
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ require 'engineyard-serverside/cli/workflows/base'
2
+ require 'engineyard-serverside/cli/workflows/helpers'
3
+
4
+ module EY
5
+ module Serverside
6
+ module CLI
7
+ module Workflows
8
+
9
+ # DeployingApplications is a Workflow that deploys the application
10
+ # specified by the incoming options
11
+ class DeployingApplications < Base
12
+ include Helpers
13
+
14
+ private
15
+ def procedure
16
+ propagate_serverside
17
+
18
+ deployer.deploy
19
+ end
20
+
21
+ def task_name
22
+ 'deploy'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'engineyard-serverside/cli/workflows/base'
2
+ require 'engineyard-serverside/cli/workflows/helpers'
3
+ require 'engineyard-serverside/maintenance'
4
+
5
+ module EY
6
+ module Serverside
7
+ module CLI
8
+ module Workflows
9
+
10
+ # DisablingMaintenance is a Workflow that removes the maintenance page
11
+ # for the application specified in the options
12
+ class DisablingMaintenance < Base
13
+ include Helpers
14
+
15
+ private
16
+ def procedure
17
+ propagate_serverside
18
+
19
+ maintenance.manually_disable
20
+ end
21
+
22
+ def task_name
23
+ 'disable_maintenance'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'engineyard-serverside/cli/workflows/base'
2
+ require 'engineyard-serverside/cli/workflows/helpers'
3
+ require 'engineyard-serverside/maintenance'
4
+
5
+ module EY
6
+ module Serverside
7
+ module CLI
8
+ module Workflows
9
+
10
+ # EnablingMaintenance is a Workflow that puts a maintenance page in
11
+ # place for the application specified in the options
12
+ class EnablingMaintenance < Base
13
+ include Helpers
14
+
15
+ private
16
+ def procedure
17
+ propagate_serverside
18
+
19
+ maintenance.manually_enable
20
+ end
21
+
22
+ def task_name
23
+ 'enable_maintenance'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ module EY
2
+ module Serverside
3
+ module CLI
4
+ module Workflows
5
+ # Undefined is an error that is raised when one attemps to perform
6
+ # a Workflow that is not fully defined
7
+ class Undefined < StandardError
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module EY
2
+ module Serverside
3
+ module CLI
4
+ module Workflows
5
+
6
+ # Helpers is a collection of methods that can be mixed into a Workflow
7
+ # to provide easy access to some of the underlying concepts for
8
+ # procedures like deploying, managing maintenance state, etc
9
+ module Helpers
10
+ def deployer
11
+ EY::Serverside::Deploy.new(servers, config, shell)
12
+ end
13
+
14
+ def maintenance
15
+ EY::Serverside::Maintenance.new(servers, config, shell)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,63 @@
1
+ require 'engineyard-serverside/cli/workflows/base'
2
+
3
+ module EY
4
+ module Serverside
5
+ module CLI
6
+ module Workflows
7
+
8
+ # IntegratingServers is a Workflow that attempts to integrate new
9
+ # servers into an existing environment
10
+ class IntegratingServers
11
+ private
12
+ def procedure
13
+ # so that we deploy to the same place there that we have here
14
+ integrate_options[:release_path] = current_app_dir.realpath.to_s
15
+
16
+ # we have to deploy the same SHA there as here
17
+ integrate_options[:branch] = current_app_dir.join('REVISION').read.strip
18
+
19
+ # always rebundle gems on integrate to make sure the instance comes up correctly.
20
+ integrate_options[:clean] = true
21
+
22
+ propagate_serverside
23
+
24
+ # We have to rsync the entire app dir, so we need all the permissions to be correct!
25
+ owner_user = config.user
26
+ owner_group = config.group
27
+
28
+ chown_command = %|find #{app_dir} \\( -not -user #{owner_user} -or -not -group #{owner_group} \\) -exec chown -h #{owner_user}:#{owner_group} "{}" +|
29
+
30
+ shell.logged_system("sudo sh -l -c '#{chown_command}'", servers.detect {|server| server.local?})
31
+
32
+ servers.run_for_each! do |server|
33
+ chown = server.command_on_server('sudo sh -l -c', chown_command)
34
+ sync = server.sync_directory_command(app_dir, options[:ignore_existing])
35
+ clean = server.command_on_server('sh -l -c', "rm -rf #{current_app_dir}")
36
+ "(#{chown}) && (#{sync}) && (#{clean})"
37
+ end
38
+
39
+ # deploy local-ref to other instances into /data/$app/local-current
40
+ EY::Serverside::Deploy.new(servers, config, shell).cached_deploy
41
+ end
42
+
43
+ def task_name
44
+ "integrate-#{options[:instances].join('-')}".gsub(/[^-.\w]/,'')
45
+ end
46
+
47
+ def integrate_options
48
+ @integrate_options ||= options.dup
49
+ end
50
+
51
+ def app_dir
52
+ @app_dir ||= Pathname.new "/data/#{options[:app]}"
53
+ end
54
+
55
+ def current_app_dir
56
+ @current_app_dir ||= app_dir.join("current")
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,36 @@
1
+ require 'engineyard-serverside/cli/workflows/base'
2
+
3
+ module EY
4
+ module Serverside
5
+ module CLI
6
+ module Workflows
7
+
8
+ # RestartingApplications is a Workflow that restarts the application
9
+ # specified in the options
10
+ class RestartingApplications < Base
11
+ private
12
+ def procedure
13
+ restart_options[:release_path] = Pathname.new(
14
+ "/data/#{options[:app]}/current"
15
+ )
16
+
17
+ propagate_serverside
18
+
19
+ EY::Serverside::Deploy.
20
+ new(servers, config, shell).
21
+ restart_with_maintenance_page
22
+
23
+ end
24
+
25
+ def restart_options
26
+ @restart_options ||= options.dup
27
+ end
28
+
29
+ def task_name
30
+ 'restart'
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ require 'engineyard-serverside/cli/workflows/base'
2
+ require 'engineyard-serverside/cli/workflows/helpers'
3
+
4
+ module EY
5
+ module Serverside
6
+ module CLI
7
+ module Workflows
8
+
9
+ # RollingBackApplications is a Workflow that attempts to roll the
10
+ # application specified in the options back to its previous deployment
11
+ class RollingBackApplications < Base
12
+ include Helpers
13
+
14
+ private
15
+ def procedure
16
+ propagate_serverside
17
+
18
+ deployer.rollback
19
+ end
20
+
21
+ def task_name
22
+ 'rollback'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end