capistrano_multiconfig_parallel 0.12.6 → 0.12.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -1
  3. data/README.md +106 -145
  4. data/lib/capistrano_multiconfig_parallel/all.rb +1 -0
  5. data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb +8 -13
  6. data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +2 -2
  7. data/lib/capistrano_multiconfig_parallel/celluloid/rake_worker.rb +2 -2
  8. data/lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb +1 -1
  9. data/lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb +8 -5
  10. data/lib/capistrano_multiconfig_parallel/celluloid/web_server.rb +5 -5
  11. data/lib/capistrano_multiconfig_parallel/extensions/input_stream.rb +1 -0
  12. data/lib/capistrano_multiconfig_parallel/extensions/output_stream.rb +3 -2
  13. data/lib/capistrano_multiconfig_parallel/extensions/rake.rb +2 -2
  14. data/lib/capistrano_multiconfig_parallel/extensions/{extension_helper.rb → rake_hook_actor.rb} +2 -1
  15. data/lib/capistrano_multiconfig_parallel/{helpers → managers}/base_manager.rb +9 -11
  16. data/lib/capistrano_multiconfig_parallel/{helpers → managers}/multi_app_manager.rb +0 -0
  17. data/lib/capistrano_multiconfig_parallel/{helpers → managers}/single_app_manager.rb +0 -0
  18. data/lib/capistrano_multiconfig_parallel/managers/standard_deploy.rb +48 -0
  19. data/lib/capistrano_multiconfig_parallel/multi_app_helpers/dependency_tracker.rb +20 -18
  20. data/lib/capistrano_multiconfig_parallel/version.rb +1 -1
  21. metadata +7 -7
  22. data/lib/capistrano_multiconfig_parallel/helpers/standard_deploy.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25e6110be90cc4ffefe82988627c73a2983780f1
4
- data.tar.gz: 9a61abb50db0a315291e91bacc453914fd097a11
3
+ metadata.gz: 2cf871544abbc31ba4cab9436d3654743594a4f2
4
+ data.tar.gz: 5e0b3a2767357c53e6be436b32c036d413bc0bc4
5
5
  SHA512:
6
- metadata.gz: 41baad24badf82947488ec801d0d87a6e7782ee61df3e1274b6b116e9809e6caf783681847739a42022f1d0f380b43a2a71256bd2eb01fdf4d01052b2a1b0764
7
- data.tar.gz: 2ff8407f1b4cf649d1c56eaa363f16d93117ccebe51653462259221f44504fd95132360b4dd43c4fae4e2af25f3fc49d8bf349c1d9319c82a08cd1bd9bc2d01a
6
+ metadata.gz: f4a837d2d7ffd39ad0a349eadb68a5b135fc1e06500826f712f3062dafef5b7f2a1e50c5eea52c6aec9a570c94bc046a8bf273db4091564db068f07f6d5ad52c
7
+ data.tar.gz: 1d12a6259cab92782f4bd5be40ef9dfb0d2dbade29f01bc1e218b06e77999f2cd38fb3b4735f4fdb4f3257f655d40c6d3816939f2047e3fc6a260399e2fec46d
data/.rubocop.yml CHANGED
@@ -3,6 +3,8 @@ AllCops:
3
3
  - capistrano_multiconfig_parallel.gemspec
4
4
  - bin/**/*
5
5
  - Guardfile
6
+ - vendor/**/*
7
+ - Rakefile
6
8
 
7
9
  Documentation:
8
10
  Enabled: true
@@ -65,4 +67,3 @@ Style/ExtraSpacing:
65
67
 
66
68
  Style/FileName:
67
69
  Enabled: false
68
-
data/README.md CHANGED
@@ -1,93 +1,67 @@
1
1
  capistrano_multiconfig_parallel
2
- ==================
2
+ ===============================
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/capistrano_multiconfig_parallel.svg)](http://badge.fury.io/rb/capistrano_multiconfig_parallel)
5
- [![Repo Size](https://ruby-gem-downloads-badge.herokuapp.com/repo_size/bogdanRada/capistrano_multiconfig_parallel)](https://github.com/bogdanRada/capistrano_multiconfig_parallel)
6
- [![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/capistrano_multiconfig_parallel?type=total&style=dynamic)](https://github.com/bogdanRada/capistrano_multiconfig_parallel)
7
- [![Maintenance Status](http://stillmaintained.com/bogdanRada/capistrano_multiconfig_parallel.png)](https://github.com/bogdanRada/capistrano_multiconfig_parallel)
4
+ [![Gem Version](https://badge.fury.io/rb/capistrano_multiconfig_parallel.svg)](http://badge.fury.io/rb/capistrano_multiconfig_parallel) [![Repo Size](https://reposs.herokuapp.com/?path=bogdanRada/capistrano_multiconfig_parallel)](https://github.com/bogdanRada/capistrano_multiconfig_parallel) [![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/capistrano_multiconfig_parallel?type=total&style=dynamic)](https://github.com/bogdanRada/capistrano_multiconfig_parallel) [![Maintenance Status](http://stillmaintained.com/bogdanRada/capistrano_multiconfig_parallel.png)](https://github.com/bogdanRada/capistrano_multiconfig_parallel)
8
5
 
9
6
  DEMO
10
- --------
7
+ ----
11
8
 
12
9
  [![capistrano multiconfig parallel ](img/parallel_demo.png)](#features)
13
10
 
14
11
  Description
15
- --------
16
- CapistranoMulticonfigParallel is a simple ruby implementation that allows you to run multiple tasks in parallel for multiple applications and uses websockets for inter-process communication and has a interactive menu
12
+ -----------
17
13
 
18
- IMPORTANT! The whole reason for this gem was for using [Caphub][caphub] in a more easy way and allowing you to run tasks in parallel for multiple aplications .
19
- However this can be used for normal applications also, if you want for example to deploy your app to multiple sandboxes on development environment
20
- or even deploy in parallel to multiple stages.
14
+ CapistranoMulticonfigParallel is a simple ruby implementation that allows you to run multiple tasks in parallel for multiple applications and uses websockets for inter-process communication and has a interactive menu
21
15
 
22
- CAUTION!! PLEASE READ CAREFULLY!! Capistrano is not thread-safe. However in order to work around this problem, each of the task is executing inside a thread that spawns a new process in order to run capistrano tasks
23
- The thread monitors the process. This works well, however if the tasks you are executing is working with files, you might get into deadlocks because multiple proceses try to access same resource.
24
- Instead of using files , please consider using StringIO instead.
16
+ IMPORTANT! The whole reason for this gem was for using [Caphub](https://github.com/railsware/caphub) in a more easy way and allowing you to run tasks in parallel for multiple aplications . However this can be used for normal applications also, if you want for example to deploy your app to multiple sandboxes on development environment or even deploy in parallel to multiple stages.
25
17
 
26
- [caphub]: https://github.com/railsware/caphub
18
+ CAUTION!! PLEASE READ CAREFULLY!! Capistrano is not thread-safe. However in order to work around this problem, each of the task is executing inside a thread that spawns a new process in order to run capistrano tasks The thread monitors the process. This works well, however if the tasks you are executing is working with files, you might get into deadlocks because multiple proceses try to access same resource. Instead of using files , please consider using StringIO instead.
27
19
 
28
20
  Requirements
29
- --------
30
- 1. [Ruby 1.9.x or Ruby 2.x.x][ruby]
31
- 2. [ActiveSuport >= 4.2.0][activesupport]
32
- 3. [celluloid-pmap >= 0.2.0][celluloid_pmap]
33
- 5. [composable_state_machine >= 1.0.2][composable_state_machine]
34
- 6. [terminal-table >= 1.4.5][terminal_table]
35
- 7. [colorize] [colorize]
36
- 8. [eventmachine >= 1.0.7] [eventmachine]
37
- 9. [right_popen >= 1.1.3] [right_popen]
38
- 10. [capistrano-multiconfig >= 3.0.8] [capistrano-multiconfig]
39
- 11. [capistrano >= 3.0] [capistrano]
40
- 12. [configliere >= 0.4] [configliere]
41
- 13. [inquirer >= 0.2] [inquirer]
42
- 14. [devnull >= 0.1] [inquirer]
43
-
44
- [ruby]: http://www.ruby-lang.org
45
- [activesupport]:https://rubygems.org/gems/activesupport
46
- [capistrano_multiconfig_parallel]:https://github.com/bogdanRada/capistrano_multiconfig_parallel
47
- [celluloid_pmap]:https://github.com/jwo/celluloid-pmap
48
- [composable_state_machine]: https://github.com/swoop-inc/composable_state_machine
49
- [terminal_table]: https://github.com/tj/terminal-table
50
- [formatador]: https://github.com/geemus/formatador
51
- [colorize]: https://github.com/fazibear/colorize
52
- [eventmachine]: https://github.com/eventmachine/eventmachine
53
- [right_popen]: https://github.com/rightscale/right_popen
54
- [capistrano-multiconfig]: https://github.com/railsware/capistrano-multiconfig
55
- [capistrano]: https://github.com/capistrano/capistrano/
56
- [configliere]: https://github.com/infochimps-platform/configliere
57
- [inquirer]: https://github.com/arlimus/inquirer.rb
58
- [devnull]: https://github.com/maraigue/devnull
21
+ ------------
22
+
23
+ 1. [Ruby 1.9.x or Ruby 2.x.x](http://www.ruby-lang.org)
24
+ 2. [ActiveSuport >= 4.2.0](https://rubygems.org/gems/activesupport)
25
+ 3. [celluloid-pmap >= 0.2.0](https://github.com/jwo/celluloid-pmap)
26
+ 4. [composable_state_machine >= 1.0.2](https://github.com/swoop-inc/composable_state_machine)
27
+ 5. [terminal-table >= 1.4.5](https://github.com/tj/terminal-table)
28
+ 6. [colorize](https://github.com/fazibear/colorize)
29
+ 7. [eventmachine >= 1.0.7](https://github.com/eventmachine/eventmachine)
30
+ 8. [right_popen >= 1.1.3](https://github.com/rightscale/right_popen)
31
+ 9. [capistrano-multiconfig >= 3.0.8](https://github.com/railsware/capistrano-multiconfig)
32
+ 10. [capistrano >= 3.0](https://github.com/capistrano/capistrano/)
33
+ 11. [configliere >= 0.4](https://github.com/infochimps-platform/configliere)
34
+ 12. [inquirer >= 0.2](https://github.com/arlimus/inquirer.rb)
35
+ 13. [devnull >= 0.1](https://github.com/arlimus/inquirer.rb)
59
36
 
60
37
  Compatibility
61
- --------
38
+ -------------
62
39
 
63
40
  Rails >3.0 only. MRI 1.9.x, 2.x
64
41
 
65
42
  Ruby 1.8 is not officially supported. We will accept further compatibilty pull-requests but no upcoming versions will be tested against it.
66
43
 
67
- Rubinius and Jruby support temporarily dropped due to Rails 4 incompatibility.
68
-
44
+ Rubinius and Jruby support temporarily dropped due to Rails 4 incompatibility.
69
45
 
70
46
  Installation Instructions
71
- --------
47
+ -------------------------
72
48
 
73
49
  Add the following to your Gemfile:
74
-
50
+
75
51
  ```ruby
76
52
  gem "capistrano_multiconfig_parallel"
77
53
  ```
78
54
 
79
-
80
55
  Add the following to your Capfile after requiring **capistrano** and **capistrano-multiconfig**
81
-
56
+
82
57
  ```ruby
83
58
  require 'capistrano_multiconfig_parallel'
84
59
  ```
85
60
 
86
- Please read [Release Details][release-details] if you are upgrading. We break backward compatibility between large ticks but you can expect it to be specified at release notes.
87
- [release-details]: https://github.com/bogdanRada/capistrano_multiconfig_parallel/releases
61
+ Please read [Release Details](https://github.com/bogdanRada/capistrano_multiconfig_parallel/releases) if you are upgrading. We break backward compatibility between large ticks but you can expect it to be specified at release notes.
88
62
 
89
63
  Default Configuration:
90
- --------
64
+ ----------------------
91
65
 
92
66
  ```yaml
93
67
  ---
@@ -95,8 +69,8 @@ multi_debug: true
95
69
  multi_secvential: false
96
70
  websocket_server:
97
71
  enable_debug: false
98
-
99
- development_stages:
72
+
73
+ development_stages:
100
74
  - development
101
75
  - webdev
102
76
 
@@ -104,7 +78,7 @@ syncronize_confirmation: true
104
78
  apply_stage_confirmation:
105
79
  - production
106
80
  task_confirmation_active: false
107
- task_confirmations:
81
+ task_confirmations:
108
82
  - deploy:symlink:release
109
83
 
110
84
  track_dependencies: false
@@ -112,51 +86,54 @@ application_dependencies: []
112
86
  ---
113
87
  ```
114
88
 
115
- Available command line options when executing a command
116
- --------
89
+ Available command line options when executing a command
90
+ -------------------------------------------------------
91
+
92
+ - --multi-debug
93
+
94
+ - if option is present and has value TRUE , will enable debugging of workers
95
+
96
+ - --multi-secvential
97
+
98
+ - If parallel executing does not work for you, you can use this option so that each process is executed normally and ouputted to the screen. However this means that all other tasks will have to wait for each other to finish before starting
117
99
 
118
- * --multi-debug
119
- * if option is present and has value TRUE , will enable debugging of workers
100
+ - --websocket_server.enable_debug
120
101
 
121
- * --multi-secvential
122
- * If parallel executing does not work for you, you can use this option so that each process is executed normally and ouputted to the screen.
123
- However this means that all other tasks will have to wait for each other to finish before starting
102
+ - if option is present and has value TRUE, will enable debugging of websocket communication between the workers
124
103
 
125
- * --websocket_server.enable_debug
126
- * if option is present and has value TRUE, will enable debugging of websocket communication between the workers
104
+ - --development_stages
127
105
 
128
- * --development_stages
129
- * if option is present and has value an ARRAY of STRINGS, each of them will be used as a development stage
106
+ - if option is present and has value an ARRAY of STRINGS, each of them will be used as a development stage
130
107
 
131
- * --syncronize_confirmation
132
- * if option is present and has value TRUE, all workers will be synchronized to wait for same task from the ***task_confirmations** Array before they execute it
108
+ - --syncronize_confirmation
133
109
 
134
- * --apply_stage_confirmation
135
- * If option is present and has value an ARRAY of STRING, each string should be the name of a stage.
136
- The confirmations will only be applied if the workers are executing tasks to one of that stage.
110
+ - if option is present and has value TRUE, all workers will be synchronized to wait for same task from the \***task_confirmations** Array before they execute it
137
111
 
138
- * --task_confirmation_active
139
- * if option is present and has value TRUE, will enable user confirmation dialogs before executing each task from option **--task_confirmations**
112
+ - --apply_stage_confirmation
140
113
 
141
- * --task_confirmations:
142
- * if option is present and has value an ARRAY of Strings, and --task_confirmation_active is TRUE , then will require a confirmation from user before executing the task.
143
- This will syncronize all workers to wait before executing that task, then a confirmation will be displayed, and when user will confirm , all workers will resume their operation.
114
+ - If option is present and has value an ARRAY of STRING, each string should be the name of a stage. The confirmations will only be applied if the workers are executing tasks to one of that stage.
144
115
 
145
- * --track_dependencies
146
- * This should be useed only for Caphub-like applications , in order to deploy dependencies of an application in parallel.
147
- This is used only in combination with option **--application_dependencies** which is described
148
- at section **[2.) Multiple applications](#multiple_apps)**
116
+ - --task_confirmation_active
117
+
118
+ - if option is present and has value TRUE, will enable user confirmation dialogs before executing each task from option **--task_confirmations**
119
+
120
+ - --task_confirmations:
121
+
122
+ - if option is present and has value an ARRAY of Strings, and --task_confirmation_active is TRUE , then will require a confirmation from user before executing the task. This will syncronize all workers to wait before executing that task, then a confirmation will be displayed, and when user will confirm , all workers will resume their operation.
123
+
124
+ - --track_dependencies
125
+
126
+ - This should be useed only for Caphub-like applications , in order to deploy dependencies of an application in parallel. This is used only in combination with option **--application_dependencies** which is described at section **[2.) Multiple applications](#multiple_apps)**
149
127
 
150
128
  Usage Instructions
151
- ========
129
+ ==================
130
+
131
+ In order to override default configurations, you can either specify them at runtime using command-line , or you can create a file in location **config/multi_cap.yml** . This settings will be overriden by command line arguments( if any)
152
132
 
153
- In order to override default configurations, you can either specify them at runtime using command-line , or you can
154
- create a file in location **config/multi_cap.yml** . This settings will be overriden by command line arguments( if any)
133
+ 1) Single Apps ( normal Rails or rack applications)
134
+ ---------------------------------------------------
155
135
 
156
- ## 1) Single Apps ( normal Rails or rack applications)
157
-
158
- CapistranoMulticonfigParallel recognizes only "development" and "webdev" as stages for development
159
- if you use other stages for development, you need to configure it like this
136
+ CapistranoMulticonfigParallel recognizes only "development" and "webdev" as stages for development if you use other stages for development, you need to configure it like this
160
137
 
161
138
  ```yaml
162
139
  ---
@@ -167,42 +144,38 @@ development_stages:
167
144
  ----
168
145
  ```
169
146
 
170
- ### 1.1) Deploying the application to multiple sandboxes ( works only with development environments)
147
+ ### 1.1) Deploying the application to multiple sandboxes ( works only with development environments)
171
148
 
172
149
  ```shell
173
150
  # <box_name> - the name of a sandbox
174
151
  #<development_stage> - the name of one of the stages you previously configured
175
152
  #<task_name> - the capistrano task that you want to execute ( example: 'deploy' )
176
153
 
177
- bundle exec multi_cap <development_stage> <task_name> BOX=<box_name>,<box_name>
154
+ bundle exec multi_cap <development_stage> <task_name> BOX=<box_name>,<box_name>
178
155
 
179
156
  ```
180
157
 
181
- If a branch is specified using **BRANCH=name** it will deploy same branch to all sandboxes
182
- The branch environment variable is then passed to the capistrano task
158
+ If a branch is specified using **BRANCH=name** it will deploy same branch to all sandboxes The branch environment variable is then passed to the capistrano task
183
159
 
184
160
  Also the script will ask if there are any other environment variables that user might want to pass to each of the sandboxes separately.
185
161
 
186
- ### 1.2) Deploying the application to multiple stages ( Using the customized command "deploy_multi_stages")
187
-
162
+ ### 1.2) Deploying the application to multiple stages ( Using the customized command "deploy_multi_stages")
188
163
 
189
164
  ```shell
190
165
 
191
166
  bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
192
167
  ```
193
- NOTE: IF you want to execute a different command on all stages, you can specify environment variable **ACTION=task_name** either when you specify the STAGES, or can be done
194
- individually for each task when prompted about additional ENV options
195
168
 
196
- If a branch is specified using **BRANCH=name** it will deploy same branch to all stages.The branch environment variable is then passed to the capistrano task
169
+ NOTE: IF you want to execute a different command on all stages, you can specify environment variable **ACTION=task_name** either when you specify the STAGES, or can be done individually for each task when prompted about additional ENV options
197
170
 
198
- Also the script will ask if there are any other environment variables that user might want to pass to each of the stages separately.
199
-
200
- If you use **capistrano-gitflow**, the workers will first deploy to all the other stages
201
- and only after staging is tagged , will trigger a new worker to start deploying to production
171
+ If a branch is specified using **BRANCH=name** it will deploy same branch to all stages.The branch environment variable is then passed to the capistrano task
202
172
 
173
+ Also the script will ask if there are any other environment variables that user might want to pass to each of the stages separately.
203
174
 
204
- ## 2.) Multiple Apps ( like [Caphub][caphub] )
175
+ If you use **capistrano-gitflow**, the workers will first deploy to all the other stages and only after staging is tagged , will trigger a new worker to start deploying to production
205
176
 
177
+ 2.) Multiple Apps ( like [Caphub](https://github.com/railsware/caphub) )
178
+ ------------------------------------------------------------------------
206
179
 
207
180
  Configuration for this types of application is more complicated
208
181
 
@@ -215,11 +188,11 @@ application_dependencies:
215
188
  dependencies: []
216
189
  - app: bar
217
190
  priority: 1
218
- dependencies:
191
+ dependencies:
219
192
  - foo
220
193
  - app: foo2
221
194
  priority: 1
222
- dependencies:
195
+ dependencies:
223
196
  - foo
224
197
  - bar
225
198
  ---
@@ -227,74 +200,62 @@ application_dependencies:
227
200
 
228
201
  The "development_stages" options is used so that the gem can know if sandboxes are allowed for those environments.
229
202
 
203
+ If you want to deploy an application with dependencies you can use the option "track_dependencies". If that options has value "true" , it will ask the user before deploying a application if he needs the dependencies deployed too
230
204
 
231
- If you want to deploy an application with dependencies you can use the option "track_dependencies".
232
- If that options has value "true" , it will ask the user before deploying a application if he needs the dependencies deployed too
233
-
234
- The dependencies are being kept in the option "application_dependencies"
235
- This is an array of hashes. Each hash has only the keys "app" ( app name), "priority" and "dependencies" ( an array of app names that this app is dependent to)
205
+ The dependencies are being kept in the option "application_dependencies" This is an array of hashes. Each hash has only the keys "app" ( app name), "priority" and "dependencies" ( an array of app names that this app is dependent to)
236
206
 
237
207
  In this example, if we execute this command:
238
208
 
239
209
  ```ruby
240
- bundle exec multi_cap foo2:development deploy
210
+ bundle exec multi_cap foo2:development deploy
241
211
  ```
242
212
 
243
213
  Will ask user if he wants to deploy the apps "foo" and "bar" , since they appear in the dependencies list for the application "foo2"
244
-
245
214
 
246
- ### 1.2) Deploying multiple application to multiple stages ( Using the customized command "deploy_multi_stages")
247
-
215
+ ### 1.2) Deploying multiple application to multiple stages ( Using the customized command "deploy_multi_stages")
248
216
 
249
217
  ```shell
250
218
 
251
219
  bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
252
220
  ```
253
221
 
254
- NOTE: IF you want to execute a different command on all stages, you can specify environment variable **ACTION=task_name** either when you specify the STAGES, or can be done
255
- individually for each task when prompted about additional ENV options
222
+ NOTE: IF you want to execute a different command on all stages, you can specify environment variable **ACTION=task_name** either when you specify the STAGES, or can be done individually for each task when prompted about additional ENV options
256
223
 
257
- If a branch is specified using **BRANCH=branch_name** it will deploy same branch to all stages.The branch environment variable is then passed to the capistrano task
258
- If you want different branches , capistrano will ask for additional ENV options for each stage, and can be specified then for each stage
224
+ If a branch is specified using **BRANCH=branch_name** it will deploy same branch to all stages.The branch environment variable is then passed to the capistrano task If you want different branches , capistrano will ask for additional ENV options for each stage, and can be specified then for each stage
259
225
 
260
- If you use **capistrano-gitflow**, the workers will first deploy to all the other stages
261
- and only after staging is tagged , will trigger a new worker to start deploying to production
226
+ If you use **capistrano-gitflow**, the workers will first deploy to all the other stages and only after staging is tagged , will trigger a new worker to start deploying to production
262
227
 
263
228
  Known Limitations
264
- --------
265
- - Currently it works only if Celluloid.cores >= 2
229
+ -----------------
266
230
 
267
- Testing
268
- --------
231
+ - Currently it works only if Celluloid.cores >= 2
232
+
233
+ Testing
234
+ -------
269
235
 
270
236
  To test, do the following:
271
237
 
272
- 1. cd to the gem root.
273
- 2. bundle install
274
- 3. bundle exec rake
238
+ 1. cd to the gem root.
239
+ 2. bundle install
240
+ 3. bundle exec rake
275
241
 
276
242
  Contributions
277
- --------
278
-
279
- Please log all feedback/issues via [Github Issues][issues]. Thanks.
243
+ -------------
280
244
 
281
- [issues]: http://github.com/bogdanRada/capistrano_multiconfig_parallel/issues
245
+ Please log all feedback/issues via [Github Issues](http://github.com/bogdanRada/capistrano_multiconfig_parallel/issues). Thanks.
282
246
 
283
247
  Contributing to capistrano_multiconfig_parallel
284
- --------
285
-
286
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
287
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
288
- * Fork the project.
289
- * Start a feature/bugfix branch.
290
- * Commit and push until you are happy with your contribution.
291
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
292
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
293
- * You can read more details about contributing in the [Contributing][contributing] document
248
+ -----------------------------------------------
294
249
 
295
- [contributing]: https://github.com/bogdanRada/capistrano_multiconfig_parallel/blob/master/CONTRIBUTING.md
250
+ - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
251
+ - Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
252
+ - Fork the project.
253
+ - Start a feature/bugfix branch.
254
+ - Commit and push until you are happy with your contribution.
255
+ - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
256
+ - Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
257
+ - You can read more details about contributing in the [Contributing](https://github.com/bogdanRada/capistrano_multiconfig_parallel/blob/master/CONTRIBUTING.md) document
296
258
 
297
259
  == Copyright
298
260
 
299
- Copyright (c) 2015 bogdanRada. See LICENSE.txt for
300
- further details.
261
+ Copyright (c) 2015 bogdanRada. See LICENSE.txt for further details.
@@ -28,6 +28,7 @@ Gem.find_files('composable_state_machine/**/*.rb').each { |path| require path }
28
28
 
29
29
  Gem.find_files('capistrano_multiconfig_parallel/initializers/**/*.rb').each { |path| require path }
30
30
  Gem.find_files('capistrano_multiconfig_parallel/helpers/**/*.rb').each { |path| require path }
31
+ Gem.find_files('capistrano_multiconfig_parallel/managers/**/*.rb').each { |path| require path }
31
32
  Gem.find_files('capistrano_multiconfig_parallel/celluloid/**/*.rb').each { |path| require path }
32
33
 
33
34
  require_relative './version'
@@ -38,7 +38,6 @@ module CapistranoMulticonfigParallel
38
38
  @worker_supervisor.supervise_as(:web_server, CapistranoMulticonfigParallel::WebServer, self.class.websocket_config)
39
39
  end
40
40
 
41
-
42
41
  def self.debug_enabled?
43
42
  debug_enabled
44
43
  end
@@ -50,13 +49,10 @@ module CapistranoMulticonfigParallel
50
49
  def self.websocket_config
51
50
  config = CapistranoMulticonfigParallel.configuration[:websocket_server]
52
51
  config.present? && config.is_a?(Hash) ? config.stringify_keys : {}
53
- config['enable_debug'] = config.fetch('enable_debug', '').to_s == 'true'
52
+ config['enable_debug'] = config.fetch('enable_debug', '').to_s == 'true'
54
53
  config
55
54
  end
56
55
 
57
-
58
-
59
-
60
56
  def generate_job_id(job)
61
57
  primary_key = SecureRandom.random_number(500)
62
58
  job['id'] = primary_key
@@ -65,7 +61,6 @@ module CapistranoMulticonfigParallel
65
61
  job['id']
66
62
  end
67
63
 
68
-
69
64
  # call to send an actor
70
65
  # a job
71
66
  def delegate(job)
@@ -117,7 +112,7 @@ module CapistranoMulticonfigParallel
117
112
  sleep(0.1) # keep current thread alive
118
113
  end
119
114
  debug("all jobs have completed #{condition}") if self.class.debug_enabled?
120
- Celluloid::Actor[:terminal_server].async.notify_time_change(CapistranoMulticonfigParallel::TerminalTable::TOPIC, type: 'output') if Celluloid::Actor[:terminal_server].alive?
115
+ Celluloid::Actor[:terminal_server].async.notify_time_change(CapistranoMulticonfigParallel::TerminalTable.topic, type: 'output') if Celluloid::Actor[:terminal_server].alive?
121
116
  end
122
117
 
123
118
  def apply_confirmations?
@@ -130,7 +125,7 @@ module CapistranoMulticonfigParallel
130
125
 
131
126
  def syncronized_confirmation?
132
127
  (syncronization_required? && !@job_manager.executes_deploy_stages?) ||
133
- (syncronization_required? && @job_manager.executes_deploy_stages? && !@job_manager.can_tag_staging? && @job_manager.confirmation_applies_to_all_workers?)
128
+ (syncronization_required? && @job_manager.executes_deploy_stages? && !@job_manager.can_tag_staging? && @job_manager.confirmation_applies_to_all_workers?)
134
129
  end
135
130
 
136
131
  def apply_confirmation_for_worker(worker)
@@ -203,10 +198,10 @@ module CapistranoMulticonfigParallel
203
198
  @jobs.pmap do |job_id, job|
204
199
  worker = get_worker_for_job(job_id)
205
200
  worker.publish_rake_event('approved' => 'yes',
206
- 'action' => 'invoke',
207
- 'job_id' => job['id'],
208
- 'task' => task
209
- )
201
+ 'action' => 'invoke',
202
+ 'job_id' => job['id'],
203
+ 'task' => task
204
+ )
210
205
  end
211
206
  end
212
207
 
@@ -225,7 +220,7 @@ module CapistranoMulticonfigParallel
225
220
 
226
221
  def can_tag_staging?
227
222
  @job_manager.can_tag_staging? &&
228
- @jobs.find { |_job_id, job| job['env'] == 'production' }.blank?
223
+ @jobs.find { |_job_id, job| job['env'] == 'production' }.blank?
229
224
  end
230
225
 
231
226
  def dispatch_new_job(job)
@@ -86,7 +86,7 @@ module CapistranoMulticonfigParallel
86
86
 
87
87
  def generate_command
88
88
  <<-CMD
89
- #{cd_working_directory} && RAILS_ENV=#{@env_name} bundle exec multi_cap #{@task_argv.join(' ')}
89
+ #{cd_working_directory} && RAILS_ENV=#{@env_name} bundle exec multi_cap #{@task_argv.join(' ')}
90
90
  CMD
91
91
  end
92
92
 
@@ -138,7 +138,7 @@ module CapistranoMulticonfigParallel
138
138
 
139
139
  def message_is_for_stdout?(message)
140
140
  message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['action'] == 'stdout'
141
- end
141
+ end
142
142
 
143
143
  def message_is_about_a_task?(message)
144
144
  message.present? && message.is_a?(Hash) && message['action'].present? && message['job_id'].present? && message['task'].present?
@@ -14,7 +14,7 @@ module CapistranoMulticonfigParallel
14
14
  default_settings
15
15
  custom_attributes
16
16
  initialize_subscription
17
- end
17
+ end
18
18
 
19
19
  def custom_attributes
20
20
  @publisher_channel = "worker_#{@job_id}"
@@ -25,7 +25,7 @@ module CapistranoMulticonfigParallel
25
25
  def publish_new_work(env, new_options = {})
26
26
  work(env, @options.merge(new_options))
27
27
  publish_to_worker(task_data)
28
- end
28
+ end
29
29
 
30
30
  def wait_execution(name = task_name, time = 0.1)
31
31
  # info "Before waiting #{name}"
@@ -43,7 +43,7 @@ module CapistranoMulticonfigParallel
43
43
  end
44
44
 
45
45
  def actor_notify_state_change(current_state, event, new_state)
46
- @actor.send_msg(CapistranoMulticonfigParallel::TerminalTable::TOPIC, type: 'event', message: "Going from #{current_state} to #{new_state} due to a #{event} event")
46
+ @actor.send_msg(CapistranoMulticonfigParallel::TerminalTable.topic, type: 'event', message: "Going from #{current_state} to #{new_state} due to a #{event} event")
47
47
  end
48
48
  end
49
49
  end
@@ -6,7 +6,10 @@ module CapistranoMulticonfigParallel
6
6
  include Celluloid
7
7
  include Celluloid::Notifications
8
8
  include Celluloid::Logger
9
- TOPIC = 'sshkit_terminal'
9
+
10
+ def self.topic
11
+ 'sshkit_terminal'
12
+ end
10
13
 
11
14
  def initialize(manager, job_manager)
12
15
  @manager = manager
@@ -15,11 +18,11 @@ module CapistranoMulticonfigParallel
15
18
  end
16
19
 
17
20
  def run
18
- subscribe(CapistranoMulticonfigParallel::TerminalTable::TOPIC, :notify_time_change)
21
+ subscribe(CapistranoMulticonfigParallel::TerminalTable.topic, :notify_time_change)
19
22
  end
20
23
 
21
24
  def notify_time_change(topic, message)
22
- return unless topic == CapistranoMulticonfigParallel::TerminalTable::TOPIC
25
+ return unless topic == CapistranoMulticonfigParallel::TerminalTable.topic
23
26
  default_headings = ['Job ID', 'Job UUID', 'App/Stage', 'Action', 'ENV Variables', 'Current Task']
24
27
  # if CapistranoMulticonfigParallel.show_task_progress
25
28
  # default_headings << 'Total'
@@ -107,7 +110,7 @@ module CapistranoMulticonfigParallel
107
110
  details = get_worker_details(job_id, worker)
108
111
 
109
112
  row = [{ value: count.to_s },
110
- { value: job_id.to_s },
113
+ { value: job_id.to_s },
111
114
  { value: details['full_stage'] },
112
115
  { value: details['action_name'] },
113
116
  { value: details['env_options'] },
@@ -142,7 +145,7 @@ module CapistranoMulticonfigParallel
142
145
  total_tasks = worker_dry_running?(worker) ? nil : tasks.size
143
146
  task_index = worker_dry_running?(worker) ? 0 : tasks.index(current_task.to_s).to_i + 1
144
147
  percent = percent_of(task_index, total_tasks)
145
- result = worker_dry_running?(worker) ? 'Please wait.. building the progress bars' : "Progress [#{sprintf('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
148
+ result = worker_dry_running?(worker) ? 'Please wait.. building the progress bars' : "Progress [#{format('%.2f', percent)}%] (executed #{task_index} of #{total_tasks})"
146
149
  if worker.alive?
147
150
  worker.crashed? ? result.red : result.green
148
151
  else
@@ -1,11 +1,11 @@
1
1
  module CapistranoMulticonfigParallel
2
- # rubocop:disable ClassLength
3
- class WebServer < CelluloidPubsub::WebServer
4
-
2
+ # class used to start the web server for websockets
3
+ class WebServer < CelluloidPubsub::WebServer
5
4
  def initialize(*args)
6
5
  super(*args)
7
- rescue
8
- #fails silently
6
+ rescue => exc
7
+ CapistranoMulticonfigParallel.log_message(exc)
8
+ # fails silently
9
9
  end
10
10
  end
11
11
  end
@@ -1,4 +1,5 @@
1
1
  module CapistranoMulticonfigParallel
2
+ # class used to hook into the input stream
2
3
  class InputStream
3
4
  def self.hook(actor, stringio)
4
5
  $stdin = new($stdin, actor, stringio)
@@ -1,4 +1,5 @@
1
1
  module CapistranoMulticonfigParallel
2
+ # class used to hook into the output stream
2
3
  class OutputStream
3
4
  def self.hook(stringio)
4
5
  $stdout = new($stdout, stringio)
@@ -27,6 +28,6 @@ module CapistranoMulticonfigParallel
27
28
 
28
29
  def method_missing(name, *args, &block)
29
30
  @real.send name, *args, &block
30
- end
31
- end
31
+ end
32
+ end
32
33
  end
@@ -1,9 +1,9 @@
1
- require_relative './extension_helper'
1
+ require_relative './rake_hook_actor'
2
2
  Rake::Task.class_eval do
3
3
  alias_method :original_execute, :execute
4
4
 
5
5
  def execute(*args)
6
- rake = CapistranoMulticonfigParallel::ExtensionHelper.new(ENV, self)
6
+ rake = CapistranoMulticonfigParallel::RakeHookActor.new(ENV, self)
7
7
  rake.work do
8
8
  original_execute(*args)
9
9
  end
@@ -3,7 +3,8 @@ require_relative '../celluloid/rake_worker'
3
3
  require_relative './input_stream'
4
4
  require_relative './output_stream'
5
5
  module CapistranoMulticonfigParallel
6
- class ExtensionHelper
6
+ # class used to handle the rake worker and sets all the hooks before and after running the worker
7
+ class RakeHookActor
7
8
  attr_accessor :task, :env
8
9
  def initialize(env, task)
9
10
  @env = env
@@ -49,8 +49,6 @@ module CapistranoMulticonfigParallel
49
49
  run
50
50
  end
51
51
 
52
-
53
-
54
52
  def initialize_data
55
53
  @application = custom_command? ? nil : @top_level_tasks.first.split(':').reverse[1]
56
54
  @stage = custom_command? ? nil : @top_level_tasks.first.split(':').reverse[0]
@@ -61,26 +59,26 @@ module CapistranoMulticonfigParallel
61
59
  @original_argv = @argv.clone
62
60
  end
63
61
 
64
-
65
62
  def parse_task_string(string) # :nodoc:
66
63
  /^([^\[]+)(?:\[(.*)\])$/ =~ string.to_s
67
64
 
68
- name = $1
69
- remaining_args = $2
65
+ name = Regexp.last_match(1)
66
+ remaining_args = Regexp.last_match(2)
70
67
 
71
68
  return string, [] unless name
72
69
  return name, [] if remaining_args.empty?
73
70
 
74
71
  args = []
75
72
 
76
- begin
73
+ loop do
77
74
  /((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
78
75
 
79
- remaining_args = $2
80
- args << $1.gsub(/\\(.)/, '\1')
81
- end while remaining_args
76
+ remaining_args = Regexp.last_match(2)
77
+ args << Regexp.last_match(1).gsub(/\\(.)/, '\1')
78
+ break if remaining_args.blank?
79
+ end
82
80
 
83
- return name, args
81
+ [name, args]
84
82
  end
85
83
 
86
84
  def verify_options_custom_command(options)
@@ -105,7 +103,7 @@ module CapistranoMulticonfigParallel
105
103
  def process_jobs
106
104
  return unless @jobs.present?
107
105
  if CapistranoMulticonfigParallel.execute_in_sequence
108
- @jobs.each { |job| CapistranoMulticonfigParallel::StandardDeploy.execute_standard_deploy(job) }
106
+ @jobs.each { |job| CapistranoMulticonfigParallel::StandardDeploy.new(job) }
109
107
  else
110
108
  run_async_jobs
111
109
  end
@@ -0,0 +1,48 @@
1
+ require 'fileutils'
2
+ module CapistranoMulticonfigParallel
3
+ # class used to find application dependencies
4
+ class StandardDeploy
5
+ include FileUtils
6
+
7
+ attr_accessor :app, :stage, :action, :task_arguments, :env_options
8
+ def initialize(options)
9
+ @app = options.fetch('app', '')
10
+ @stage = options.fetch('env', 'development')
11
+ @action = options.fetch('action', 'deploy')
12
+ @task_arguments = options.fetch('task_arguments:', [])
13
+ @env_options = options.fetch('env_options', {})
14
+ execute_standard_deploy
15
+ end
16
+
17
+ def job_stage
18
+ @app.present? ? "#{@app}:#{@stage}" : "#{@stage}"
19
+ end
20
+
21
+ def capistrano_action(action)
22
+ argv = task_arguments.present? ? "[#{@task_arguments}]" : ''
23
+ "#{action}#{argv}"
24
+ end
25
+
26
+ def setup_command_line_standard(options)
27
+ opts = ''
28
+ options.each do |key, value|
29
+ opts << "#{key}=#{value} " if value.present?
30
+ end
31
+ opts
32
+ end
33
+
34
+ def build_capistrano_task(action = @action, env = {})
35
+ environment_options = setup_command_line_standard(@env_options.merge(env))
36
+ "bundle exec cap #{job_stage} #{capistrano_action(action)} #{environment_options} --trace"
37
+ end
38
+
39
+ def execute_standard_deploy(action = @action)
40
+ command = build_capistrano_task(action)
41
+ puts("\n\n\n Executing '#{command}' \n\n\n .")
42
+ sh("#{command}")
43
+ # rescue => ex
44
+ # CapistranoMulticonfigParallel.log_message(ex)
45
+ # execute_standard_deploy('deploy:rollback') if action.blank? && @name == 'deploy'
46
+ end
47
+ end
48
+ end
@@ -9,6 +9,26 @@ module CapistranoMulticonfigParallel
9
9
  @job_manager = job_manager
10
10
  end
11
11
 
12
+ def fetch_apps_needed_for_deployment(application, action)
13
+ applications = []
14
+ if @job_manager.custom_command? && @job_manager.multi_apps?
15
+ apps_selected = all_websites_return_applications_selected
16
+ applications = get_applications_to_deploy(action, apps_selected)
17
+ elsif CapistranoMulticonfigParallel.configuration.track_dependencies
18
+ if application.present?
19
+ applications = get_applications_to_deploy(action, [application.camelcase])
20
+ applications = applications.delete_if { |hash| hash['app'] == application }
21
+ else
22
+ applications = []
23
+ end
24
+ else
25
+ applications = []
26
+ end
27
+ applications
28
+ end
29
+
30
+ private
31
+
12
32
  def application_dependencies
13
33
  deps = CapistranoMulticonfigParallel.configuration.track_dependencies ? CapistranoMulticonfigParallel.configuration.application_dependencies : []
14
34
  deps.present? && deps.is_a?(Array) ? deps.map(&:stringify_keys) : []
@@ -88,23 +108,5 @@ module CapistranoMulticonfigParallel
88
108
  return applications_to_deploy
89
109
  end
90
110
  end
91
-
92
- def fetch_apps_needed_for_deployment(application, action)
93
- applications = []
94
- if @job_manager.custom_command? && @job_manager.multi_apps?
95
- apps_selected = all_websites_return_applications_selected
96
- applications = get_applications_to_deploy(action, apps_selected)
97
- elsif CapistranoMulticonfigParallel.configuration.track_dependencies
98
- if application.present?
99
- applications = get_applications_to_deploy(action, [application.camelcase])
100
- applications = applications.delete_if { |hash| hash['app'] == application }
101
- else
102
- applications = []
103
- end
104
- else
105
- applications = []
106
- end
107
- applications
108
- end
109
111
  end
110
112
  end
@@ -8,7 +8,7 @@ module CapistranoMulticonfigParallel
8
8
  module VERSION
9
9
  MAJOR = 0
10
10
  MINOR = 12
11
- TINY = 6
11
+ TINY = 7
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_multiconfig_parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.6
4
+ version: 0.12.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-23 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid-pmap
@@ -627,16 +627,16 @@ files:
627
627
  - lib/capistrano_multiconfig_parallel/celluloid/web_server.rb
628
628
  - lib/capistrano_multiconfig_parallel/cli.rb
629
629
  - lib/capistrano_multiconfig_parallel/configuration.rb
630
- - lib/capistrano_multiconfig_parallel/extensions/extension_helper.rb
631
630
  - lib/capistrano_multiconfig_parallel/extensions/input_stream.rb
632
631
  - lib/capistrano_multiconfig_parallel/extensions/output_stream.rb
633
632
  - lib/capistrano_multiconfig_parallel/extensions/rake.rb
634
- - lib/capistrano_multiconfig_parallel/helpers/base_manager.rb
635
- - lib/capistrano_multiconfig_parallel/helpers/multi_app_manager.rb
636
- - lib/capistrano_multiconfig_parallel/helpers/single_app_manager.rb
637
- - lib/capistrano_multiconfig_parallel/helpers/standard_deploy.rb
633
+ - lib/capistrano_multiconfig_parallel/extensions/rake_hook_actor.rb
638
634
  - lib/capistrano_multiconfig_parallel/initializers/conf.rb
639
635
  - lib/capistrano_multiconfig_parallel/initializers/default.yml
636
+ - lib/capistrano_multiconfig_parallel/managers/base_manager.rb
637
+ - lib/capistrano_multiconfig_parallel/managers/multi_app_manager.rb
638
+ - lib/capistrano_multiconfig_parallel/managers/single_app_manager.rb
639
+ - lib/capistrano_multiconfig_parallel/managers/standard_deploy.rb
640
640
  - lib/capistrano_multiconfig_parallel/multi_app_helpers/dependency_tracker.rb
641
641
  - lib/capistrano_multiconfig_parallel/multi_app_helpers/interactive_menu.rb
642
642
  - lib/capistrano_multiconfig_parallel/version.rb
@@ -1,41 +0,0 @@
1
- require 'fileutils'
2
- module CapistranoMulticonfigParallel
3
- # class used to find application dependencies
4
- class StandardDeploy
5
- extend FileUtils
6
-
7
- def self.setup_command_line_standard(options)
8
- opts = ''
9
- options.each do |key, value|
10
- opts << "#{key}=#{value} " if value.present?
11
- end
12
- opts
13
- end
14
-
15
- def self.execute_standard_deploy(options)
16
- app = options.fetch('app', '')
17
- stage = options.fetch('env', 'development')
18
- action_name = options.fetch('action', 'deploy')
19
- action = "#{action_name}[#{options.fetch('task_arguments:', []).join(',')}]"
20
- arguments = setup_command_line_standard(options.fetch('env_options', {}))
21
- job_stage = app.present? ? "#{app}:#{stage}" : "#{stage}"
22
-
23
- command = "bundle exec cap #{job_stage} #{action} #{arguments}"
24
- puts("\n\n\n Executing '#{command}' \n\n\n .")
25
- sh("#{command}")
26
- rescue => ex
27
- CapistranoMulticonfigParallel.log_message(ex)
28
- if @name == 'deploy'
29
- begin
30
- action = "deploy:rollback[#{options.fetch(:task_arguments, []).join(',')}]"
31
- command = "bundle exec cap #{app}:#{stage} #{action} #{arguments}"
32
- puts("\n\n\n Executing #{command} \n\n\n .")
33
- sh("#{command}")
34
- rescue => exception
35
- CapistranoMulticonfigParallel.log_message(exception)
36
- # nothing to do if rollback fails
37
- end
38
- end
39
- end
40
- end
41
- end