capistrano_multiconfig_parallel 1.7.2 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -2
  3. data/README.md +38 -36
  4. data/V1_README.md +351 -0
  5. data/capistrano_multiconfig_parallel.gemspec +5 -8
  6. data/lib/capistrano_multiconfig_parallel/all.rb +3 -7
  7. data/lib/capistrano_multiconfig_parallel/application.rb +10 -5
  8. data/lib/capistrano_multiconfig_parallel/base.rb +11 -11
  9. data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_manager.rb +3 -2
  10. data/lib/capistrano_multiconfig_parallel/celluloid/celluloid_worker.rb +32 -20
  11. data/lib/capistrano_multiconfig_parallel/celluloid/child_process.rb +3 -0
  12. data/lib/capistrano_multiconfig_parallel/celluloid/state_machine.rb +21 -14
  13. data/lib/capistrano_multiconfig_parallel/celluloid/terminal_table.rb +4 -3
  14. data/lib/capistrano_multiconfig_parallel/classes/cursor.rb +6 -2
  15. data/lib/capistrano_multiconfig_parallel/classes/dependency_tracker.rb +1 -1
  16. data/lib/capistrano_multiconfig_parallel/classes/job.rb +38 -13
  17. data/lib/capistrano_multiconfig_parallel/classes/job_command.rb +154 -15
  18. data/lib/capistrano_multiconfig_parallel/cli.rb +10 -26
  19. data/lib/capistrano_multiconfig_parallel/configuration/default.yml +1 -1
  20. data/lib/capistrano_multiconfig_parallel/helpers/application_helper.rb +26 -2
  21. data/lib/capistrano_multiconfig_parallel/helpers/capistrano_helper.rb +1 -1
  22. data/lib/capistrano_multiconfig_parallel/helpers/configuration.rb +3 -3
  23. data/lib/capistrano_multiconfig_parallel/helpers/gem_helper.rb +2 -1
  24. data/lib/capistrano_multiconfig_parallel/helpers/internal_helper.rb +18 -2
  25. data/lib/capistrano_multiconfig_parallel/version.rb +5 -4
  26. metadata +20 -60
  27. data/lib/capistrano_multiconfig_parallel/celluloid/rake_worker.rb +0 -132
  28. data/lib/capistrano_multiconfig_parallel/classes/input_stream.rb +0 -34
  29. data/lib/capistrano_multiconfig_parallel/classes/output_stream.rb +0 -33
  30. data/lib/capistrano_multiconfig_parallel/classes/rake_task_hooks.rb +0 -88
  31. data/lib/capistrano_multiconfig_parallel/initializers/capistrano2.rb +0 -37
  32. data/lib/capistrano_multiconfig_parallel/initializers/rake.rb +0 -11
  33. data/lib/capistrano_multiconfig_parallel/initializers/websocket.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df9044606e9e0fdcd6ddca0397da37f5c18740c4
4
- data.tar.gz: 99532dc1ae6d5f85cc635ffcbbf77e108de2f1a2
3
+ metadata.gz: 90465ac1914f4d1a52d75ea58d467fd3a9de07d0
4
+ data.tar.gz: c742e9d38e06da28fba7cff73425a135c9d3cfa9
5
5
  SHA512:
6
- metadata.gz: 0d3c213e8647e1c9f80d6dff69c99ed1e04f22b7ff19c06a2a6235f2f1d31d7ce6bdf7768fe620a1a2993ec95062073382337ad9fe4eca637c0fb45373a18a9c
7
- data.tar.gz: 6f06a8d205cbf93d1f799fb57ca28666ab1fc6bfdb63b54885b663106ca65ce6f87367b2962329c218a77203a52e2420dd54e7706caebfd71b734555c7d010fb
6
+ metadata.gz: 51b96d92426e0c983a9cecf6db95be7c305cf45fd090d41f9e3535dd245ffc0074a49d7359fe9eb4a0c21c1e78ae90f3785d172d8f0a115881b61ac7e387f092
7
+ data.tar.gz: 8c115ff9f2ec2baf17333191e08bb451e3980a732c3c85b94dfc66cc5b8d4a344fdbf3acd5c543921e98cabdd77a45d8acd8e3ccc98f80307bbe803311195e06
data/Gemfile CHANGED
@@ -2,8 +2,6 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
-
6
-
7
5
  if RUBY_VERSION >= "2.2.0"
8
6
  gem 'activesupport', '>= 4.0', '>= 4.0'
9
7
  gem 'rack' , '>= 1.4', '>= 1.4'
data/README.md CHANGED
@@ -17,42 +17,37 @@ IMPORTANT! The whole reason for this gem was for using [Caphub](https://github.c
17
17
 
18
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.
19
19
 
20
- NEW Improvements in version 1.2.0
21
- ---------------------------------
20
+ NEW Improvements started in version 2.0.0.alpha ( currently gem is in beta version)
21
+ ---------------------------------------
22
22
 
23
- - support for Celluloid 0.17 was added
23
+ - Code for handling websocket events when a task is invoked was moved to a new gem [capistrano_sentinel](https://github.com/bogdanRada/capistrano_sentinel)
24
+ - You can now deploy applications from anywhere on your computer without having to add this gem to the Gemfile, however you need to add the [capistrano_sentinel](https://github.com/bogdanRada/capistrano_sentinel) gem to your Gemfile, if you want to use this .
25
+ - And only create anywhere on your computer a YAML file as described in section **[2.2) Deploying multiple applications from a central location](#22-deploying-multiple-applications-from-a-central-location)**
26
+ - If you don't add the **capistrano_sentinel** to each of your applications, the executable of this gem will automatically create a new file "Gemfile.multi_cap" in the root of each of the applications that you are deploying, where the [capistrano_sentinel](https://github.com/bogdanRada/capistrano_sentinel) gem will be included and will use that Gemfile when doing deploys.
27
+ - The Capfile file of each of the applications that you are deploying will also be automatically changed to require [capistrano_sentinel](https://github.com/bogdanRada/capistrano_sentinel) if you haven't done so yet.
28
+ - The changes to Capfile will be automatically reverted when the command finishes ( with success or error ) if the [capistrano_sentinel](https://github.com/bogdanRada/capistrano_sentinel) gem is not part of your Gemfile
29
+ - If you are using RVM and there is a .rvmrc file in your project root directory and bash is available , the script will use bash emulator in order to properly load RVM gemsets because .rvmrc files need trusting
30
+ - **Dont use BUNDLE EXEC command when running the executable for this gem unless you are using version 1 or this gem is part of the Gemfile of the application you are using. Otherwise just use the ```multi_cap``` executable without any prefix**
24
31
 
25
- NEW Improvements in version 1.1.0
26
- ---------------------------------
27
-
28
- - a lot of refactoring and bug fixes
29
- - added posibility to run the deployments from a single directory and is described at section **[2.2) Deploying multiple applications from a central location](#22-deploying-multiple-applications-from-a-central-location)**
30
-
31
- NEW Improvements in version 1.0.5
32
- ---------------------------------
33
-
34
- - added support for Capistrano version 2 (Capistrano 3 was already supported)
35
- - a lot of refactoring and bug fixes
36
- - removed BRANCH variable ( this needs to be passed when asked for additional env options for each job!!!) ( for Capistrano 2 should be **-S branch=branch_name**, for Capistrano 3 should be **BRANCH=branch_name**, or could be something else depending on your configuration).
32
+ If you are using a older version than 2.0 please refer to this [README for version 1.7.2 or lower](https://github.com/bogdanRada/capistrano_multiconfig_parallel/blob/master/V1_README.md)
33
+ ==========================================================================================================================================================
37
34
 
38
35
  Requirements
39
36
  ------------
40
37
 
41
- 1. [ActiveSuport >= 4.2.0](https://rubygems.org/gems/activesupport)
38
+ 1. [celluloid >= 0.16](https://github.com/celluloid/celluloid)
42
39
  2. [celluloid-pmap >= 0.2.2](https://github.com/jwo/celluloid-pmap)
43
- 3. [celluloid_pubsub >= 0.1.0](https://github.com/bogdanRada/celluloid_pubsub)
44
- 4. [celluloid-websocket-client >= 0.0.1](https://github.com/jeremyd/celluloid-websocket-client)
45
- 5. [composable_state_machine >= 1.0.2](https://github.com/swoop-inc/composable_state_machine)
46
- 6. [terminal-table >= 1.5.2](https://github.com/tj/terminal-table)
47
- 7. [colorize >= 0.7](https://github.com/fazibear/colorize)
48
- 8. [eventmachine >= 1.0.3](https://github.com/eventmachine/eventmachine)
49
- 9. [right_popen >= 1.1.3](https://github.com/rightscale/right_popen)
50
- 10. [capistrano >= 2.0](https://github.com/capistrano/capistrano/)
51
- 11. [configliere >= 0.4](https://github.com/infochimps-platform/configliere)
52
- 12. [inquirer >= 0.2](https://github.com/arlimus/inquirer.rb)
53
- 13. [devnull >= 0.1](https://github.com/arlimus/inquirer.rb)
54
- 14. [rack >= 1.6](http://rack.github.io/)
55
- 15. [rake >= 10.4](https://github.com/ruby/rake)
40
+ 3. [celluloid_pubsub >= 0.8.3](https://github.com/bogdanRada/celluloid_pubsub)
41
+ 4. [composable_state_machine >= 1.0.2](https://github.com/swoop-inc/composable_state_machine)
42
+ 5. [terminal-table >= 1.5.2](https://github.com/tj/terminal-table)
43
+ 6. [colorize >= 0.7](https://github.com/fazibear/colorize)
44
+ 7. [eventmachine >= 1.0.3](https://github.com/eventmachine/eventmachine)
45
+ 8. [right_popen >= 1.1.3](https://github.com/rightscale/right_popen)
46
+ 9. [ActiveSuport >= 4.2.0](https://rubygems.org/gems/activesupport)
47
+ 10. [configliere >= 0.4](https://github.com/infochimps-platform/configliere)
48
+ 11. [inquirer >= 0.2](https://github.com/arlimus/inquirer.rb)
49
+ 12. [devnull >= 0.1](https://github.com/arlimus/inquirer.rb)
50
+ 13. [capistrano_sentinel >= 1.6](http://github.com/bogdanRada/capistrano_sentinel)
56
51
 
57
52
  Compatibility
58
53
  -------------
@@ -69,13 +64,19 @@ Installation Instructions
69
64
  Add the following to your Gemfile after requiring **capistrano** and **capistrano-multiconfig**:
70
65
 
71
66
  ```ruby
72
- gem "capistrano_multiconfig_parallel"
67
+ gem "capistrano_sentinel"
73
68
  ```
74
69
 
75
70
  Add the following to your Capfile after requiring **capistrano** and **capistrano-multiconfig**
76
71
 
77
72
  ```ruby
78
- require 'capistrano_multiconfig_parallel'
73
+ require 'capistrano_sentinel'
74
+ ```
75
+
76
+ Install locally on your system the capistrano_multiconfig_parallel gem using this command :
77
+
78
+ ```ruby
79
+ gem install capistrano_multiconfig_parallel -v 2.0.0.beta
79
80
  ```
80
81
 
81
82
  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.
@@ -184,7 +185,7 @@ development_stages:
184
185
  #<development_stage> - the name of one of the stages you previously configured
185
186
  #<task_name> - the capistrano task that you want to execute ( example: 'deploy' )
186
187
 
187
- bundle exec multi_cap <development_stage> <task_name> BOX=<box_name>,<box_name>
188
+ multi_cap <development_stage> <task_name> BOX=<box_name>,<box_name>
188
189
 
189
190
  ```
190
191
 
@@ -196,7 +197,7 @@ The script will ask if there are any other environment variables that user might
196
197
 
197
198
  ```shell
198
199
 
199
- bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
200
+ multi_cap deploy_multi_stages STAGES=development, staging, production
200
201
  ```
201
202
 
202
203
  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
@@ -235,7 +236,7 @@ The dependencies are being kept in the option "application_dependencies" This is
235
236
  In this example, if we execute this command:
236
237
 
237
238
  ```ruby
238
- bundle exec multi_cap foo2:development deploy
239
+ multi_cap foo2:development deploy
239
240
  ```
240
241
 
241
242
  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,7 +245,7 @@ Will ask user if he wants to deploy the apps "foo" and "bar" , since they appear
244
245
 
245
246
  ```shell
246
247
 
247
- bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
248
+ multi_cap deploy_multi_stages STAGES=development, staging, production
248
249
  ```
249
250
 
250
251
  Demo:
@@ -261,7 +262,7 @@ If you use **capistrano-gitflow**, the workers will first deploy to all the othe
261
262
 
262
263
  This works like described in section **[2) Multiple applications](#2-multiple-apps--like-caphub-)** ), but now the **application_dependencies** Array can also have a **path** key inside each item that should point to the DocumentRoot of that application, and the configuration now accepts two new arguments **config_dir** ( this should point to the directory where the file **multi_cap.yml** resides) and **log_dir**( this can be used if you want your logs created in different directory)
263
264
 
264
- This will only work if all applications listed in the configuration file have the gem **capistrano_multiconfig_parallel** as part of their Gemfile.
265
+ This will only work if all applications listed in the configuration file have the gem **capistrano_sentinel** as part of their Gemfile.
265
266
 
266
267
  Example of configuration: - create a directory anywhere (e.g.**mkdir /tmp/app**\) - create a Gemfile and add only this two lines:
267
268
 
@@ -310,6 +311,7 @@ Known Limitations
310
311
  -----------------
311
312
 
312
313
  - Currently it works only if Celluloid.cores >= 2
314
+ - RVM users that use .rvmrc files need to have bash terminal emulator available
313
315
 
314
316
  Testing
315
317
  -------
data/V1_README.md ADDED
@@ -0,0 +1,351 @@
1
+ capistrano_multiconfig_parallel
2
+ ===============================
3
+
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) [![Analytics](https://ga-beacon.appspot.com/UA-72570203-1/bogdanRada/capistrano_multiconfig_parallel)](https://github.com/bogdanRada/capistrano_multiconfig_parallel) [![Join the chat at https://gitter.im/bogdanRada/capistrano_multiconfig_parallel](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bogdanRada/capistrano_multiconfig_parallel?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
+
6
+
7
+ This README is for version 1.7.2 or lower. Please consider upgrading to latest version. Or at least try it out :)
8
+ -------------------------------------------------------------------------------------------------------------------
9
+
10
+
11
+ DEMO
12
+ ----
13
+
14
+ [![capistrano multiconfig parallel ](img/parallel_demo-min.png)](#features)
15
+
16
+ Description
17
+ -----------
18
+
19
+ 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
20
+
21
+ 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.
22
+
23
+ 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.
24
+
25
+ NEW improvements in version 2.0.0.alpha
26
+
27
+ - Code for handling capistrano requests was moved to a new gem [capistrano_sentinel](https://github.com/bogdanRada/capistrano_sentinel]
28
+
29
+ NEW Improvements in version 1.2.0
30
+ ---------------------------------
31
+
32
+ - support for Celluloid 0.17 was added
33
+
34
+ NEW Improvements in version 1.1.0
35
+ ---------------------------------
36
+
37
+ - a lot of refactoring and bug fixes
38
+ - added posibility to run the deployments from a single directory and is described at section **[2.2) Deploying multiple applications from a central location](#22-deploying-multiple-applications-from-a-central-location)**
39
+
40
+ NEW Improvements in version 1.0.5
41
+ ---------------------------------
42
+
43
+ - added support for Capistrano version 2 (Capistrano 3 was already supported)
44
+ - a lot of refactoring and bug fixes
45
+ - removed BRANCH variable ( this needs to be passed when asked for additional env options for each job!!!) ( for Capistrano 2 should be **-S branch=branch_name**, for Capistrano 3 should be **BRANCH=branch_name**, or could be something else depending on your configuration).
46
+
47
+ Requirements
48
+ ------------
49
+
50
+ 1. [ActiveSuport >= 4.2.0](https://rubygems.org/gems/activesupport)
51
+ 2. [celluloid-pmap >= 0.2.2](https://github.com/jwo/celluloid-pmap)
52
+ 3. [celluloid_pubsub >= 0.1.0](https://github.com/bogdanRada/celluloid_pubsub)
53
+ 4. [celluloid-websocket-client >= 0.0.1](https://github.com/jeremyd/celluloid-websocket-client)
54
+ 5. [composable_state_machine >= 1.0.2](https://github.com/swoop-inc/composable_state_machine)
55
+ 6. [terminal-table >= 1.5.2](https://github.com/tj/terminal-table)
56
+ 7. [colorize >= 0.7](https://github.com/fazibear/colorize)
57
+ 8. [eventmachine >= 1.0.3](https://github.com/eventmachine/eventmachine)
58
+ 9. [right_popen >= 1.1.3](https://github.com/rightscale/right_popen)
59
+ 10. [capistrano >= 2.0](https://github.com/capistrano/capistrano/)
60
+ 11. [configliere >= 0.4](https://github.com/infochimps-platform/configliere)
61
+ 12. [inquirer >= 0.2](https://github.com/arlimus/inquirer.rb)
62
+ 13. [devnull >= 0.1](https://github.com/arlimus/inquirer.rb)
63
+ 14. [rack >= 1.6](http://rack.github.io/)
64
+ 15. [rake >= 10.4](https://github.com/ruby/rake)
65
+
66
+ Compatibility
67
+ -------------
68
+
69
+ Rails >3.0 only. [MRI 1.9.x or 2.x](http://www.ruby-lang.org)
70
+
71
+ Ruby 1.8 is not officially supported. We will accept further compatibilty pull-requests but no upcoming versions will be tested against it.
72
+
73
+ Rubinius and Jruby support temporarily dropped due to Rails 4 incompatibility.
74
+
75
+ Installation Instructions
76
+ -------------------------
77
+
78
+ Add the following to your Gemfile after requiring **capistrano** and **capistrano-multiconfig**:
79
+
80
+ ```ruby
81
+ gem "capistrano_multiconfig_parallel"
82
+ ```
83
+
84
+ Add the following to your Capfile after requiring **capistrano** and **capistrano-multiconfig**
85
+
86
+ ```ruby
87
+ require 'capistrano_multiconfig_parallel'
88
+ ```
89
+
90
+ 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.
91
+
92
+ Default Configuration:
93
+ ----------------------
94
+
95
+ ```yaml
96
+ ---
97
+ multi_debug: true
98
+ multi_secvential: false
99
+ websocket_server:
100
+ enable_debug: false
101
+ adapter: ''
102
+ log_file_path: './log/multi_cap_websocket.log'
103
+ terminal:
104
+ clear_screen: false
105
+
106
+ development_stages:
107
+ - development
108
+ - webdev
109
+
110
+ apply_stage_confirmation:
111
+ - production
112
+ task_confirmations:
113
+ - deploy:symlink:release
114
+
115
+ application_dependencies: []
116
+ ---
117
+ ```
118
+
119
+ Available command line options when executing a command
120
+ -------------------------------------------------------
121
+
122
+ - --multi-debug
123
+
124
+ - if option is present and has value TRUE , will enable debugging of workers
125
+
126
+ - --multi-secvential
127
+
128
+ - 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
129
+
130
+ - --websocket_server.enable_debug
131
+
132
+ - if option is present and has value TRUE, will enable debugging of websocket communication between the workers
133
+
134
+ - --websocket_server.adapter
135
+
136
+ - Can be specified a different adapter for the websocket reactor class used for publish subscribe communication
137
+
138
+ - --websocket_server.log_file_path
139
+
140
+ - Enables the logging of websocket communication into a different file -
141
+
142
+ - --terminal.clear_screen
143
+
144
+ - Enables the clear screen to happen before the table status is displayed on screen
145
+
146
+ - --config_dir
147
+
148
+ - The directory where the config file (multi_cap.yml) is located. The gem will try to detect if file exist in current directory from where the script is runnning
149
+
150
+ - --log_dir
151
+
152
+ - The path where the log files will be created. By default it depends on the **config_dir**. It will create a **log** directory in the same directory as the configuration directory
153
+
154
+ - --development_stages
155
+
156
+ - if option is present and has value an ARRAY of STRINGS, each of them will be used as a development stage
157
+
158
+ - --apply_stage_confirmation
159
+
160
+ - 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.
161
+
162
+ - --task_confirmations:
163
+
164
+ - if option is present and has value an ARRAY of Strings (Task Names), 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.
165
+
166
+ - --application_dependencies
167
+
168
+ - This should be used only for Caphub-like applications , in order to deploy dependencies of an application in parallel and is described at section **[2.) Multiple applications](#2-multiple-apps--like-caphub-)**
169
+
170
+ Usage Instructions
171
+ ==================
172
+
173
+ 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)
174
+
175
+ 1) Single Apps ( normal Rails or rack applications)
176
+ ---------------------------------------------------
177
+
178
+ CapistranoMulticonfigParallel recognizes only "development" and "webdev" as stages for development if you use other stages for development, you need to configure it like this
179
+
180
+ ```yaml
181
+ ---
182
+ development_stages:
183
+ - development
184
+ - webdev
185
+ - something_custom
186
+ ----
187
+ ```
188
+
189
+ ### 1.1) Deploying the application to multiple sandboxes ( works only with development environments)
190
+
191
+ ```shell
192
+ # <box_name> - the name of a sandbox
193
+ #<development_stage> - the name of one of the stages you previously configured
194
+ #<task_name> - the capistrano task that you want to execute ( example: 'deploy' )
195
+
196
+ bundle exec multi_cap <development_stage> <task_name> BOX=<box_name>,<box_name>
197
+
198
+ ```
199
+
200
+ For Capistrano 2 application, the jobs will receive **-S box=<box_name>,<box_name>**, although you will use **BOX** when running the command. This so that i can maintain compatibility between versions
201
+
202
+ The script will ask if there are any other environment variables that user might want to pass to each of the sandboxes separately.
203
+
204
+ ### 2.1) Deploying the application to multiple stages ( Using the customized command "deploy_multi_stages")
205
+
206
+ ```shell
207
+
208
+ bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
209
+ ```
210
+
211
+ 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
212
+
213
+ The script will ask if there are any other environment variables that user might want to pass to each of the stages separately.
214
+
215
+ 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
216
+
217
+ 2.) Multiple Apps ( like [Caphub](https://github.com/railsware/caphub) )
218
+ ------------------------------------------------------------------------
219
+
220
+ Configuration for this types of application is more complicated
221
+
222
+ ```yaml
223
+ ---
224
+ application_dependencies:
225
+ - app: foo'
226
+ priority: 1
227
+ dependencies: []
228
+ - app: bar
229
+ priority: 1
230
+ dependencies:
231
+ - foo
232
+ - app: foo2
233
+ priority: 1
234
+ dependencies:
235
+ - foo
236
+ - bar
237
+ ---
238
+ ```
239
+
240
+ The "development_stages" options is used so that the gem can know if sandboxes are allowed for those environments.
241
+
242
+ 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)
243
+
244
+ In this example, if we execute this command:
245
+
246
+ ```ruby
247
+ bundle exec multi_cap foo2:development deploy
248
+ ```
249
+
250
+ Will ask user if he wants to deploy the apps "foo" and "bar" , since they appear in the dependencies list for the application "foo2"
251
+
252
+ ### 2.1) Deploying multiple application to multiple stages ( Using the customized command "deploy_multi_stages")
253
+
254
+ ```shell
255
+
256
+ bundle exec multi_cap deploy_multi_stages STAGES=development, staging, production
257
+ ```
258
+
259
+ Demo:
260
+
261
+ [![capistrano multiconfig parallel ](img/interactive_menu-min.png)](#features)
262
+
263
+ 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
264
+
265
+ The script will ask for additional ENV options for each stage.
266
+
267
+ 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
268
+
269
+ ### 2.2) [Deploying multiple applications from a central location](#deploy-from-central-location)
270
+
271
+ This works like described in section **[2) Multiple applications](#2-multiple-apps--like-caphub-)** ), but now the **application_dependencies** Array can also have a **path** key inside each item that should point to the DocumentRoot of that application, and the configuration now accepts two new arguments **config_dir** ( this should point to the directory where the file **multi_cap.yml** resides) and **log_dir**( this can be used if you want your logs created in different directory)
272
+
273
+ This will only work if all applications listed in the configuration file have the gem **capistrano_multiconfig_parallel** as part of their Gemfile.
274
+
275
+ Example of configuration: - create a directory anywhere (e.g.**mkdir /tmp/app**\) - create a Gemfile and add only this two lines:
276
+
277
+ ```ruby
278
+ source 'http://rubygems.org'
279
+
280
+ gem 'capistrano_multiconfig_parallel'
281
+ ```
282
+
283
+ or you could install it directly from command line:
284
+
285
+ ```shell
286
+ gem install capistrano_multiconfig_parallel
287
+ ```
288
+
289
+ Then create a file called **multi_cap.yml** in the root folder and create a configuration like this.
290
+
291
+ ```yaml
292
+ ---
293
+ application_dependencies:
294
+ - app: foo'
295
+ priority: 1
296
+ path: /some/path/to/foo
297
+ dependencies: []
298
+ - app: bar
299
+ priority: 1
300
+ path: /some/path/to/bar
301
+ dependencies:
302
+ - foo
303
+ - app: foo2
304
+ priority: 1
305
+ path: /some/path/to/foo2
306
+ dependencies:
307
+ - foo
308
+ - bar
309
+ ---
310
+ ```
311
+
312
+ and then you can run like you would normally do: (Apppend **bundle exec** to the below command only if you have a Gemfile)
313
+
314
+ ```shell
315
+ multi_cap foo2:development deploy
316
+ ```
317
+
318
+ Known Limitations
319
+ -----------------
320
+
321
+ - Currently it works only if Celluloid.cores >= 2
322
+
323
+ Testing
324
+ -------
325
+
326
+ To test, do the following:
327
+
328
+ 1. cd to the gem root.
329
+ 2. bundle install
330
+ 3. bundle exec rake
331
+
332
+ Contributions
333
+ -------------
334
+
335
+ Please log all feedback/issues via [Github Issues](http://github.com/bogdanRada/capistrano_multiconfig_parallel/issues). Thanks.
336
+
337
+ Contributing to capistrano_multiconfig_parallel
338
+ -----------------------------------------------
339
+
340
+ - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
341
+ - Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
342
+ - Fork the project.
343
+ - Start a feature/bugfix branch.
344
+ - Commit and push until you are happy with your contribution.
345
+ - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
346
+ - 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.
347
+ - You can read more details about contributing in the [Contributing](https://github.com/bogdanRada/capistrano_multiconfig_parallel/blob/master/CONTRIBUTING.md) document
348
+
349
+ == Copyright
350
+
351
+ Copyright (c) 2015 bogdanRada. See LICENSE.txt for further details.
@@ -17,30 +17,27 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ['lib']
18
18
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
 
20
- s.add_runtime_dependency 'celluloid', '>= 0.16', '>= 0.16.0'
20
+ s.add_runtime_dependency 'celluloid', '>= 0.16', '>= 0.16'
21
21
  s.add_runtime_dependency 'celluloid-pmap', '~> 0.2', '>= 0.2.2'
22
- s.add_runtime_dependency 'celluloid_pubsub', '~> 0.8', '>= 0.8.2'
23
- s.add_runtime_dependency 'celluloid-websocket-client', '~> 0.0', '>= 0.0.1'
22
+ s.add_runtime_dependency 'celluloid_pubsub', '~> 0.8', '>= 0.8.3'
24
23
  s.add_runtime_dependency 'composable_state_machine', '~> 1.0', '>= 1.0.2'
25
24
  s.add_runtime_dependency 'terminal-table', '~> 1.5', '>= 1.5.2'
26
25
  s.add_runtime_dependency 'colorize', '~> 0.7', '>= 0.7'
27
26
  s.add_runtime_dependency 'eventmachine', '~> 1.0', '>= 1.0.3'
28
27
  s.add_runtime_dependency 'right_popen', '~> 3.0', '>= 3.0.1'
29
- s.add_runtime_dependency 'capistrano','>= 2.0','>= 2.0'
30
- s.add_runtime_dependency 'activesupport', '>= 4.0','>= 4.0'
28
+ s.add_runtime_dependency 'activesupport', '>= 5.0','>= 5.0'
31
29
  s.add_runtime_dependency 'configliere', '~> 0.4', '>=0.4'
32
30
  s.add_runtime_dependency 'inquirer', '~> 0.2', '>= 0.2'
33
31
  s.add_runtime_dependency 'devnull','~> 0.1', '>= 0.1'
34
- s.add_runtime_dependency 'rack', '>= 1.6', '>= 1.6'
35
- s.add_runtime_dependency 'rake', '>= 10.4', '>= 10.4'
32
+ s.add_runtime_dependency 'capistrano_sentinel', '>= 0.0', '>= 0.0.14'
36
33
 
34
+ s.add_development_dependency 'rake', '>= 10.4', '>= 10.4'
37
35
  s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4'
38
36
  s.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11'
39
37
  s.add_development_dependency 'simplecov-summary', '~> 0.0.4', '>= 0.0.4'
40
38
  s.add_development_dependency 'mocha', '~> 1.1', '>= 1.1'
41
39
  s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7'
42
40
 
43
-
44
41
  s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7'
45
42
  s.add_development_dependency 'redcarpet', '~> 3.3', '>= 3.3'
46
43
  s.add_development_dependency 'github-markup', '~> 1.3', '>= 1.3.3'
@@ -19,8 +19,7 @@ require 'terminal-table'
19
19
  require 'configliere'
20
20
  require 'devnull'
21
21
  require 'inquirer'
22
- require 'rack'
23
- require 'rake'
22
+ require "capistrano_sentinel"
24
23
 
25
24
  require 'etc'
26
25
  require 'logger'
@@ -29,18 +28,15 @@ require 'pp'
29
28
  require 'yaml'
30
29
  require 'stringio'
31
30
  require 'io/console'
31
+ require 'shellwords'
32
32
 
33
33
  # fix error with not files that can not be found
34
34
  Gem.find_files('composable_state_machine/**/*.rb').each { |path| require path }
35
35
 
36
- %w(helpers classes celluloid core_ext).each do |folder_name|
36
+ %w(helpers classes celluloid).each do |folder_name|
37
37
  Gem.find_files("capistrano_multiconfig_parallel/#{folder_name}/**/*.rb").each { |path| require path }
38
38
  end
39
39
 
40
40
  %w(version base application).each do |filename|
41
41
  Gem.find_files("capistrano_multiconfig_parallel/#{filename}.rb").each { |path| require path }
42
42
  end
43
-
44
- %w(initializers).each do |folder_name|
45
- Gem.find_files("capistrano_multiconfig_parallel/#{folder_name}/**/*.rb").each { |path| require path }
46
- end
@@ -2,7 +2,7 @@ require_relative './helpers/base_actor_helper'
2
2
  module CapistranoMulticonfigParallel
3
3
  # finds app dependencies, shows menu and delegates jobs to celluloid manager
4
4
  class Application
5
- include CapistranoMulticonfigParallel::BaseActorHelper
5
+ include CapistranoMulticonfigParallel::ApplicationHelper
6
6
 
7
7
  attr_reader :stage_apps, :top_level_tasks, :jobs, :condition, :manager, :dependency_tracker, :application, :stage, :name, :args, :argv, :default_stage
8
8
 
@@ -89,10 +89,10 @@ module CapistranoMulticonfigParallel
89
89
  end
90
90
 
91
91
  def check_before_starting
92
- @dependency_tracker = CapistranoMulticonfigParallel::DependencyTracker.new(Actor.current)
92
+ @dependency_tracker = CapistranoMulticonfigParallel::DependencyTracker.new(self)
93
93
  @default_stage = configuration.development_stages.present? ? configuration.development_stages.first : 'development'
94
94
  @condition = Celluloid::Condition.new
95
- @manager = CapistranoMulticonfigParallel::CelluloidManager.new(Actor.current)
95
+ @manager = CapistranoMulticonfigParallel::CelluloidManager.new(self)
96
96
  end
97
97
 
98
98
  def collect_jobs(options = {}, &_block)
@@ -199,7 +199,7 @@ module CapistranoMulticonfigParallel
199
199
  result = @condition.wait
200
200
  return unless result.present?
201
201
  @manager.terminate
202
- terminate
202
+ #terminate
203
203
  end
204
204
 
205
205
  def prepare_job(options)
@@ -214,7 +214,7 @@ module CapistranoMulticonfigParallel
214
214
 
215
215
  env_options = options['env_options']
216
216
  job_env_options = custom_command? ? env_options.except(action_key) : env_options
217
- job = CapistranoMulticonfigParallel::Job.new(Actor.current, options.merge(
217
+ job = CapistranoMulticonfigParallel::Job.new(self, options.merge(
218
218
  action: custom_command? && env_options[action_key].present? ? env_options[action_key] : options['action'],
219
219
  env_options: job_env_options,
220
220
  path: options.fetch('path', nil)
@@ -266,5 +266,10 @@ module CapistranoMulticonfigParallel
266
266
  prepare_job(options)
267
267
  end
268
268
  end
269
+ def jobs_restore_application_state
270
+ @jobs.each do |job|
271
+ job.rollback_changes_to_application
272
+ end
273
+ end
269
274
  end
270
275
  end