capistrano_multiconfig_parallel 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a78671478f02eea81290937d810f8d201a64035
4
- data.tar.gz: 5c4a60eb2789c9b1df47f226b9afabbc29ad532d
3
+ metadata.gz: 7e02536cc3ccf434baaac3f46f7b84b91d6eda10
4
+ data.tar.gz: 0631bf39e10f727ac6180498b18e5f997a4cf610
5
5
  SHA512:
6
- metadata.gz: d43f718c5aeea36c005ddbba82aca7135e318d122fbb29f7c2b83d23f467866ea1c6f454a3d944f5ae888672433721de667618ffb1793ef9778351c9da86d75a
7
- data.tar.gz: 8e4b19c83d44d3df10878ba3212718a565c50d1b5db0d79f248effb2e3e6b338396cb9c74af6d0922a7a57993196ff5f10765659fc573c821bc86f04e3e54dcc
6
+ metadata.gz: f1fe7728cd4b3ccee8d7b698707e0bf2dac2668552f37b0eaae8dda5d317dace22acc607b3f081f466bb6eb485c8b690b45072ee19998bc2ed253dcba25240f9
7
+ data.tar.gz: 43cc88221c00e64976f2d2a367e3704ad7ce2c9b2b406e63765d3ed7fc8e7f19601cad34da711ae957dbee0c0a3803a59e16c08d3a153e7f2214485b83fe537f
data/README.md CHANGED
@@ -6,6 +6,11 @@ capistrano_multiconfig_parallel
6
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
7
  [![Maintenance Status](http://stillmaintained.com/bogdanRada/capistrano_multiconfig_parallel.png)](https://github.com/bogdanRada/capistrano_multiconfig_parallel)
8
8
 
9
+ DEMO
10
+ --------
11
+
12
+ [![capistrano multiconfig parallel ](img/parallel_demo.png)](#features)
13
+
9
14
  Description
10
15
  --------
11
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
@@ -33,7 +38,8 @@ Requirements
33
38
  10. [right_popen >= 1.1.3] [right_popen]
34
39
  11. [capistrano-multiconfig >= 3.0.8] [capistrano-multiconfig]
35
40
  12. [capistrano >= 3.0] [capistrano]
36
- 13. [configurations >= 2.0.0] [configurations]
41
+ 13. [configliere >= 0.4] [configliere]
42
+ 14. [inquirer >= 0.2] [inquirer]
37
43
 
38
44
  [ruby]: http://www.ruby-lang.org
39
45
  [activesupport]:https://rubygems.org/gems/activesupport
@@ -47,7 +53,8 @@ Requirements
47
53
  [right_popen]: https://github.com/rightscale/right_popen
48
54
  [capistrano-multiconfig]: https://github.com/railsware/capistrano-multiconfig
49
55
  [capistrano]: https://github.com/capistrano/capistrano/
50
- [configurations]: https://github.com/beatrichartz/configurations
56
+ [configliere]: https://github.com/infochimps-platform/configliere
57
+ [inquirer]: https://github.com/arlimus/inquirer.rb
51
58
 
52
59
  Compatibility
53
60
  --------
@@ -77,23 +84,83 @@ Add the following to your Capfile:
77
84
  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.
78
85
  [release-details]: https://github.com/bogdanRada/capistrano_multiconfig_parallel/releases
79
86
 
80
- Usage Instructions
87
+ Default Configuration:
81
88
  --------
82
89
 
83
- [![capistrano multiconfig parallel ](img/parallel_demo.png)](#features)
90
+ ```yaml
91
+ ---
92
+ multi_debug: true
93
+ multi_progres: false
94
+ multi_secvential: false
95
+ websocket_server:
96
+ enable_debug: false
97
+
98
+ development_stages:
99
+ - development
100
+ - webdev
101
+
102
+ task_confirmation_active: false
103
+ task_confirmations:
104
+ - deploy:symlink:release
105
+
106
+ track_dependencies: false
107
+ application_dependencies: []
108
+ ---
109
+ ```
110
+
111
+ Available command line options when executing a command
112
+ --------
113
+
114
+ * --multi-debug
115
+ * if option is present and has value TRUE , will enable debugging of workers
116
+
117
+ * --multi-progress
118
+ * If option is present and has value TRUE will first execute before any process , same task but with option "--dry-run" in order to show progress of how many tasks are in total for that task and what is the progress of executing
119
+ This will slow down the workers , because they will execute twice the same task.
120
+
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
124
+
125
+ * --websocket_server.enable_debug
126
+ * if option is present and has value TRUE, will enable debugging of websocket communication between the workers
127
+
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
84
130
 
85
- 1. Single Apps ( normal Rails or rack applications)
131
+ * --task_confirmation_active
132
+ * if option is present and has value TRUE, will enable user confirmation dialogs before executing each task from option **--task_confirmations**
133
+
134
+ * --task_confirmations:
135
+ * 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.
136
+ 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.
137
+
138
+ * --track_dependencies
139
+ * This should be useed only for Caphub-like applications , in order to deploy dependencies of an application in parallel.
140
+ This is used only in combination with option **--application_dependencies** which is described
141
+ at section **[2.) Multiple applications](#multiple_apps)**
142
+
143
+ Usage Instructions
144
+ ========
145
+
146
+ In order to override default configurations, you can either specify them at runtime using command-line , or you can
147
+ create a file in location **config/multi_cap.yml** . This settings will be overriden by command line arguments( if any)
148
+
149
+ ## 1) Single Apps ( normal Rails or rack applications)
86
150
 
87
151
  CapistranoMulticonfigParallel recognizes only "development" and "webdev" as stages for development
88
- if you use other stages for development, you need to configure it like this. This will override the default configuration.
89
- You will need to require this file in your Capfile also.
90
-
91
- ```ruby
92
- CapistranoMulticonfigParallel.configure do |c|
93
- c.development_stages = ["development", "some_other_stage"]
94
- end
152
+ if you use other stages for development, you need to configure it like this
153
+
154
+ ```yaml
155
+ ---
156
+ development_stages:
157
+ - development
158
+ - webdev
159
+ - something_custom
160
+ ----
95
161
  ```
96
- ### Deploying the application to multiple sandboxes ( works only with development environments)
162
+
163
+ ### 1.1) Deploying the application to multiple sandboxes ( works only with development environments)
97
164
 
98
165
  ```shell
99
166
  # <box_name> - the name of a sandbox
@@ -110,7 +177,7 @@ The branch environment variable is then passed to the capistrano task
110
177
 
111
178
  Also the script will ask if there are any other environment variables that user might want to pass to each of the sandboxes separately.
112
179
 
113
- ### Deploying the application to multiple stages ( Using the customized command "deploy_stages")
180
+ ### 1.2) Deploying the application to multiple stages ( Using the customized command "deploy_stages")
114
181
 
115
182
 
116
183
  ```shell
@@ -126,33 +193,32 @@ Also the script will ask if there are any other environment variables that user
126
193
 
127
194
 
128
195
 
129
- 2. Multiple Apps ( like [Caphub][caphub] )
196
+ ## 2.) Multiple Apps ( like [Caphub][caphub] )
130
197
 
131
198
 
132
199
  Configuration for this types of application is more complicated
133
200
 
134
- ```ruby
135
- CapistranoMulticonfigParallel.configure do |c|
136
- c.development_stages = ['development', 'webdev']
137
- c.task_confirmation_active = true
138
- c.task_confirmations = ['deploy:symlink:release']
139
- c.track_dependencies = true
140
- c.application_dependencies = [
141
- { app: 'blog', priority: 1, dependencies: [] },
142
- { app: 'blog2', priority: 2, dependencies: ['blog'] },
143
- { app: 'blog3', priority: 3, dependencies: ['blog', 'blog2'] },
144
- ]
145
- end
201
+ ```yaml
202
+ ---
203
+ track_dependencies: true
204
+ application_dependencies:
205
+ - app: foo'
206
+ priority: 1
207
+ dependencies: []
208
+ - app: bar
209
+ priority: 1
210
+ dependencies:
211
+ - foo
212
+ - app: foo2
213
+ priority: 1
214
+ dependencies:
215
+ - foo
216
+ - bar
217
+ ---
146
218
  ```
147
219
 
148
220
  The "development_stages" options is used so that the gem can know if sandboxes are allowed for those environments.
149
221
 
150
- The "task_confirmation_active" option can have only two values:
151
- - false - all threads are executing normally without needing confirmation from user
152
- - true - means threads need confirmation from user ( Can we used to synchronize all processes to wait before executing a task)
153
- For this we use the option "task_confirmations" which is a array with string.
154
- Each string is the name of the task that needs confirmation.
155
-
156
222
 
157
223
  If you want to deploy an application with dependencies you can use the option "track_dependencies".
158
224
  If that options has value "true" , it will ask the user before deploying a application if he needs the dependencies deployed too
@@ -160,32 +226,14 @@ If that options has value "true" , it will ask the user before deploying a appli
160
226
  The dependencies are being kept in the option "application_dependencies"
161
227
  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)
162
228
 
163
- Default Configuration:
164
- --------
229
+ In this example, if we execute this command:
165
230
 
166
231
  ```ruby
167
- CapistranoMulticonfigParallel.configure do |c|
168
- c.task_confirmations = ['deploy:symlink:release']
169
- c.task_confirmation_active = false
170
- c.track_dependencies = false
171
- c.websocket_server = { enable_debug: false }
172
- c.development_stages = ['development', 'webdev']
173
- end
232
+ bundle exec multi_cap foo2:development deploy
174
233
  ```
175
234
 
176
- Available command line options when executing a command
177
- --------
178
-
179
- --multi-debug
180
- If option is present , will enable debugging of workers
181
-
182
- --multi-progress
183
- If option is present will first execute before any process , same task but with option "--dry-run" in order to show progress of how many tasks are in total for that task and what is the progress of executing
184
- This will slow down the workers , because they will execute twice the same task.
185
-
186
- --multi-secvential
187
- 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.
188
- However this means that all other tasks will have to wait for each other to finish before starting
235
+ Will ask user if he wants to deploy the apps "foo" and "bar" , since they appear in the dependencies list for the application "foo2"
236
+
189
237
 
190
238
  Testing
191
239
  --------
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency 'capistrano-multiconfig','~> 3.0', '>= 3.0.8'
29
29
  s.add_runtime_dependency 'capistrano','~> 3.0','>= 3.0'
30
30
  s.add_runtime_dependency 'activesupport', '~> 4.0','>= 4.0'
31
- s.add_runtime_dependency 'configurations', '~> 2.0', '2.0.0'
31
+ s.add_runtime_dependency 'configliere', '~> 0.4', '>=0.4'
32
32
  s.add_runtime_dependency 'inquirer', '~> 0.2', '>= 0.2'
33
33
 
34
34
  s.add_development_dependency 'rspec-rails', '~> 2.0', '>= 2.0'
@@ -20,7 +20,6 @@ require 'capistrano/all'
20
20
  require 'fileutils'
21
21
  require 'logger'
22
22
  require 'pp'
23
- require 'configurations'
24
23
  # fix error with not files that can not be found
25
24
  Gem.find_files('composable_state_machine/**/*.rb').each { |path| require path }
26
25
 
@@ -6,35 +6,7 @@ module CapistranoMulticonfigParallel
6
6
  end
7
7
 
8
8
  def sort_options(options)
9
- super.push(multi_debug, multi_progress, multi_secvential)
10
- end
11
-
12
- def multi_debug
13
- ['--multi-debug', '-D',
14
- 'Sets the debug enabled for celluloid actors',
15
- lambda do |_value|
16
- CapistranoMulticonfigParallel::CelluloidManager.debug_enabled = true
17
- Celluloid.task_class = Celluloid::TaskThread
18
- end
19
- ]
20
- end
21
-
22
- def multi_progress
23
- ['--multi-progress', '--multi-progress',
24
- 'Sets the debug enabled for celluloid actors',
25
- lambda do |_value|
26
- CapistranoMulticonfigParallel.show_task_progress = true
27
- end
28
- ]
29
- end
30
-
31
- def multi_secvential
32
- ['--multi-secvential', '--multi-secvential',
33
- 'Sets the debug enabled for celluloid actors',
34
- lambda do |_value|
35
- CapistranoMulticonfigParallel.execute_in_sequence = true
36
- end
37
- ]
9
+ super.concat(CapistranoMulticonfigParallel.capistrano_options)
38
10
  end
39
11
 
40
12
  def top_level
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
3
  require 'bundler/setup'
4
- require 'configurations'
5
4
  require 'inquirer'
6
5
  require_relative './version'
7
6
  require_relative './configuration'
@@ -29,9 +28,9 @@ module CapistranoMulticonfigParallel
29
28
  def root
30
29
  File.expand_path(File.dirname(__dir__))
31
30
  end
32
-
31
+
33
32
  def ask_confirm(message, default)
34
- Ask.input message, default: default
33
+ Ask.input message, default: default
35
34
  end
36
35
 
37
36
  def verify_app_dependencies(stages)
@@ -51,10 +50,11 @@ module CapistranoMulticonfigParallel
51
50
  end
52
51
 
53
52
  def websokect_log_file
54
- File.join(log_directory, 'multi_cap_webscoket.log')
53
+ File.join(log_directory, 'multi_cap_websocket.log')
55
54
  end
56
55
 
57
56
  def enable_logging
57
+ CapistranoMulticonfigParallel.configuration_valid?
58
58
  return unless CapistranoMulticonfigParallel::CelluloidManager.debug_enabled
59
59
  FileUtils.mkdir_p(log_directory)
60
60
  log_file = File.open(main_log_file, 'w')
@@ -68,9 +68,11 @@ module CapistranoMulticonfigParallel
68
68
  error_message = message.respond_to?(:message) ? message.message : message.inspect
69
69
  err_backtrace = message.respond_to?(:backtrace) ? message.backtrace.join("\n\n") : ''
70
70
  if err_backtrace.present?
71
- logger.debug(class: message.class,
72
- message: error_message,
73
- backtrace: err_backtrace)
71
+ logger.debug(
72
+ class_name: message.class,
73
+ message: error_message,
74
+ backtrace: err_backtrace
75
+ )
74
76
  else
75
77
  logger.debug(message)
76
78
  end
@@ -44,12 +44,12 @@ module CapistranoMulticonfigParallel
44
44
  def self.debug_websocket?
45
45
  websocket_config['enable_debug'].to_s == 'true'
46
46
  end
47
-
47
+
48
48
  def self.websocket_config
49
- config = CapistranoMulticonfigParallel.configuration.websocket_server
49
+ config = CapistranoMulticonfigParallel.configuration[:websocket_server]
50
50
  config.present? && config.is_a?(Hash) ? config.stringify_keys : {}
51
51
  end
52
-
52
+
53
53
  def generate_job_id(job)
54
54
  primary_key = @jobs.size + 1
55
55
  job['id'] = primary_key
@@ -42,12 +42,11 @@ module CapistranoMulticonfigParallel
42
42
  def debug_enabled?
43
43
  @manager.class.debug_enabled?
44
44
  end
45
-
46
45
 
47
46
  def start_task
48
47
  debug("exec worker #{@job_id} starts task with #{@job.inspect}") if debug_enabled?
49
48
  @task_confirmations = CapistranoMulticonfigParallel.configuration.task_confirmations
50
- @client = CelluloidPubsub::Client.connect(actor: Actor.current, enable_debug: @manager.class.debug_websocket?) do |ws|
49
+ @client = CelluloidPubsub::Client.connect(actor: Actor.current, enable_debug: @manager.class.debug_websocket?) do |ws|
51
50
  ws.subscribe(@subscription_channel)
52
51
  end
53
52
  end
@@ -10,8 +10,7 @@ module CapistranoMulticonfigParallel
10
10
  if $stdout.isatty
11
11
  $stdout.sync = true
12
12
  end
13
- CapistranoMulticonfigParallel.configuration_valid?
14
- CapistranoMulticonfigParallel.verify_app_dependencies(stages) if CapistranoMulticonfigParallel.configuration.track_dependencies
13
+ CapistranoMulticonfigParallel.enable_logging
15
14
  CapistranoMulticonfigParallel::Application.new.run
16
15
  rescue Interrupt
17
16
  `stty icanon echo`
@@ -4,17 +4,127 @@ module CapistranoMulticonfigParallel
4
4
  module Configuration
5
5
  extend ActiveSupport::Concern
6
6
 
7
- included do
8
- include Configurations
7
+ class_methods do
8
+ attr_accessor :configuration
9
9
 
10
- configurable Hash, :websocket_server
11
- configurable Array, :development_stages
10
+ def configuration
11
+ @config ||= Configliere::Param.new
12
+ @config.use :commandline
13
+ command_line_params.each do |param|
14
+ @config.define param[:name], type: param[:type], description: param[:description], default: param[:default]
15
+ end
16
+ @config.merge(Settings.use(:commandline).resolve!)
17
+ @config.read config_file if File.file?(config_file)
18
+
19
+ @config.use :config_block
20
+ @config.finally do |c|
21
+ check_configuration(c)
22
+ end
23
+ @config.resolve!
24
+ rescue => ex
25
+ puts ex.inspect
26
+ puts ex.backtrace if ex.respond_to?(:backtrace)
27
+ end
28
+
29
+ def default_config
30
+ @default_config ||= Configliere::Param.new
31
+ @default_config.read File.join(CapistranoMulticonfigParallel.root.to_s, 'capistrano_multiconfig_parallel', 'initializers', 'default.yml')
32
+ @default_config.resolve!
33
+ end
34
+
35
+ def config_file
36
+ File.join(CapistranoMulticonfigParallel.detect_root.to_s, 'config', 'multi_cap.yml')
37
+ end
38
+
39
+ def command_line_params
40
+ [
41
+ {
42
+ name: 'multi_debug',
43
+ type: :boolean,
44
+ description: '[MULTI_CAP] if option is present and has value TRUE , will enable debugging of workers',
45
+ default: default_config[:multi_debug]
46
+ },
47
+ {
48
+ name: 'multi_progress',
49
+ type: :boolean,
50
+ description: "[MULTI_CAP] if option is present and has value TRUE will first execute before any process ,
51
+ same task but with option '--dry-run' in order to show progress of how many tasks are in total for that task and what is the progress of executing
52
+ This will slow down the workers , because they will execute twice the same task.",
53
+ default: default_config[:multi_progress]
54
+ },
55
+ {
56
+ name: 'multi_secvential',
57
+ type: :boolean,
58
+ description: "[MULTI_CAP] 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.
59
+ However this means that all other tasks will have to wait for each other to finish before starting ",
60
+ default: default_config[:multi_secvential]
61
+ },
62
+ {
63
+ name: 'websocket_server.enable_debug',
64
+ type: :boolean,
65
+ description: '[MULTI_CAP] if option is present and has value TRUE, will enable debugging of websocket communication between the workers',
66
+ default: default_config[:websocket_server][:enable_debug]
67
+ },
68
+ {
69
+ name: 'development_stages',
70
+ type: Array,
71
+ description: '[MULTI_CAP] if option is present and has value an ARRAY of STRINGS, each of them will be used as a development stage',
72
+ default: default_config[:development_stages]
73
+ },
74
+ {
75
+ name: 'task_confirmations',
76
+ type: Array,
77
+ description: '[MULTI_CAP] if option is present and has value TRUE, will enable user confirmation dialogs
78
+ before executing each task from option **--task_confirmations**',
79
+ default: default_config[:task_confirmations]
80
+ },
81
+ {
82
+ name: 'task_confirmation_active',
83
+ type: :boolean,
84
+ description: "[MULTI_CAP] if option is present and has value an ARRAY of Strings, and --task_confirmation_active is TRUE ,
85
+ then will require a confirmation from user before executing the task.
86
+ This will syncronize all workers to wait before executing that task, then a confirmation will be displayed,
87
+ and when user will confirm , all workers will resume their operation",
88
+ default: default_config[:task_confirmation_active]
89
+ },
90
+ {
91
+ name: 'track_dependencies',
92
+ type: :boolean,
93
+ description: "[MULTI_CAP] This should be useed only for Caphub-like applications , in order to deploy dependencies of an application in parallel.
94
+ This is used only in combination with option **--application_dependencies** which is described
95
+ at section **[2.) Multiple applications](#multiple_apps)**",
96
+ default: default_config[:track_dependencies]
97
+ },
98
+ {
99
+ name: 'application_dependencies',
100
+ type: Array,
101
+ description: "[MULTI_CAP] This is an array of hashes. Each hash has only the keys 'app' ( app name), 'priority' and 'dependencies'
102
+ ( an array of app names that this app is dependent to) ",
103
+ default: default_config[:application_dependencies]
104
+ }
105
+ ]
106
+ end
107
+
108
+ def capistrano_options
109
+ command_line_params.map do |param|
110
+ [
111
+ "--#{param[:name]}[=CAP_VALUE]",
112
+ "--#{param[:name]}",
113
+ param[:description],
114
+ lambda do |_value|
115
+ end
116
+ ]
117
+ end
118
+ end
12
119
 
13
- configurable :track_dependencies do |value|
14
- check_boolean(:track_dependencies, value)
120
+ def verify_array_of_strings(c, prop)
121
+ value = c[prop]
122
+ return unless value.present?
123
+ value.reject(&:blank?)
124
+ raise ArgumentError, 'the array must contain only task names' if value.find { |row| !row.is_a?(String) }
15
125
  end
16
126
 
17
- configurable Array, :application_dependencies do |value|
127
+ def verify_application_dependencies(value)
18
128
  value.reject { |val| val.blank? || !val.is_a?(Hash) }
19
129
  wrong = value.find do|hash|
20
130
  !Set[:app, :priority, :dependencies].subset?(hash.keys.to_set) ||
@@ -26,44 +136,33 @@ module CapistranoMulticonfigParallel
26
136
  raise ArgumentError, "invalid configuration for #{wrong.inspect}" if wrong.present?
27
137
  end
28
138
 
29
- configurable :task_confirmation_active do |value|
30
- check_boolean(:task_confirmation_active, value)
31
- end
32
-
33
- configurable Array, :task_confirmations do |value|
34
- value.reject(&:blank?)
35
- if value.find { |row| !row.is_a?(String) }
36
- raise ArgumentError, 'the array must contain only task names'
37
- end
38
- end
39
-
40
- configuration_defaults do |c|
41
- c.task_confirmations = ['deploy:symlink:release']
42
- c.task_confirmation_active = false
43
- c.track_dependencies = false
44
- c.websocket_server = { enable_debug: false }
45
- c.development_stages = ['development', 'webdev']
46
- end
47
-
48
- not_configured do |prop| # omit the arguments to get a catch-all not_configured
49
- raise NoMethodError, "Please configure the property `#{prop}` by assigning a value of type #{configuration.property_type(prop)}"
139
+ def check_boolean(c, prop)
140
+ return unless c[prop].present?
141
+ raise ArgumentError, "the property `#{prop}` must be boolean" unless [true, false, 'true', 'false'].include?(c[prop].to_s.downcase)
50
142
  end
51
143
 
52
- def self.value_is_boolean?(value)
53
- [true, false, 'true', 'false'].include?(value)
144
+ def configuration_valid?
145
+ configuration
54
146
  end
55
147
 
56
- def self.check_boolean(prop, value)
57
- unless value_is_boolean?(value)
58
- raise ArgumentError, "the property `#{prop}` must be boolean"
148
+ def check_configuration(c)
149
+ %w(multi_debug multi_progress multi_secvential task_confirmation_active track_dependencies websocket_server.enable_debug).each do |prop|
150
+ c.send("#{prop}=", c[prop.to_sym]) if check_boolean(c, prop.to_sym)
151
+ end
152
+ %w(task_confirmations development_stages).each do |prop|
153
+ c.send("#{prop}=", c[prop.to_sym]) if verify_array_of_strings(c, prop.to_sym)
59
154
  end
155
+ c.application_dependencies = c[:application_dependencies] if c[:track_dependencies].to_s.downcase == 'true' && verify_application_dependencies(c[:application_dependencies])
156
+ check_additional_config(c)
60
157
  end
61
158
 
62
- def self.configuration_valid?
63
- configuration.nil? &&
64
- configuration.task_confirmations &&
65
- ((configuration.track_dependencies && configuration.application_dependencies) ||
66
- configuration.track_dependencies == false)
159
+ def check_additional_config(c)
160
+ if c[:multi_debug].to_s.downcase == 'true'
161
+ CapistranoMulticonfigParallel::CelluloidManager.debug_enabled = true
162
+ Celluloid.task_class = Celluloid::TaskThread
163
+ end
164
+ CapistranoMulticonfigParallel.show_task_progress = true if c[:multi_progress].to_s.downcase == 'true'
165
+ CapistranoMulticonfigParallel.execute_in_sequence = true if c[:multi_secvential].to_s.downcase == 'true'
67
166
  end
68
167
  end
69
168
  end
@@ -13,6 +13,8 @@ module CapistranoMulticonfigParallel
13
13
  @top_level_tasks = top_level_tasks
14
14
  @stages = stages
15
15
  @jobs = []
16
+ CapistranoMulticonfigParallel.configuration_valid?
17
+ CapistranoMulticonfigParallel.verify_app_dependencies(@stages) if CapistranoMulticonfigParallel.configuration.track_dependencies
16
18
  end
17
19
 
18
20
  def can_start?
@@ -38,7 +40,6 @@ module CapistranoMulticonfigParallel
38
40
  @name, @args = @cap_app.parse_task_string(@top_level_tasks.second)
39
41
  @argv = @cap_app.handle_options.delete_if { |arg| arg == @stage || arg == @name || arg == @top_level_tasks.first }
40
42
  @argv = multi_fetch_argv(@argv)
41
- CapistranoMulticonfigParallel.enable_logging
42
43
  block.call if block_given?
43
44
  run
44
45
  end
@@ -58,31 +59,30 @@ module CapistranoMulticonfigParallel
58
59
  run_async_jobs(&block)
59
60
  end
60
61
  end
61
-
62
+
62
63
  def fetch_multi_stages
63
64
  stages = @argv['STAGES'].blank? ? '' : @argv['STAGES']
64
65
  stages = parse_inputted_value(value: stages).split(',').compact if stages.present?
65
66
  stages
66
67
  end
67
-
68
-
68
+
69
69
  def deploy_app(options = {})
70
70
  options = options.stringify_keys
71
- app = options['app'].is_a?(Hash) ? options['app'] : {'app' => options['app'] }
71
+ app = options['app'].is_a?(Hash) ? options['app'] : { 'app' => options['app'] }
72
72
  branch = @branch_backup.present? ? @branch_backup : @argv['BRANCH'].to_s
73
73
  call_task_deploy_app({
74
- branch: branch,
75
- app: app ,
76
- action: options['action']
77
- }.reverse_merge(options))
74
+ branch: branch,
75
+ app: app,
76
+ action: options['action']
77
+ }.reverse_merge(options))
78
78
  end
79
79
 
80
- private
81
-
80
+ private
81
+
82
82
  def call_task_deploy_app(options = {})
83
83
  options = options.stringify_keys
84
84
  main_box_name = @argv['BOX'].blank? ? '' : @argv['BOX']
85
- stage = options.fetch('stage', @default_stage )
85
+ stage = options.fetch('stage', @default_stage)
86
86
  if CapistranoMulticonfigParallel.configuration.development_stages.include?(stage) && main_box_name.present? && /^[a-z0-9,]+/.match(main_box_name)
87
87
  execute_on_multiple_boxes(main_box_name, options)
88
88
  else
@@ -167,8 +167,12 @@ module CapistranoMulticonfigParallel
167
167
 
168
168
  def get_applications_branch_from_stdin(app, app_message)
169
169
  app_name = (app.is_a?(Hash) && app[:app].present?) ? app[:app].camelcase : app
170
- app_name = app_name.present? ? app_name : "current application"
170
+ app_name = app_name.present? ? app_name : 'current application'
171
171
  message = "Please enter Branch name for #{app_name} for #{app_message}"
172
+ get_branch_name_from_stdin(message)
173
+ end
174
+
175
+ def get_branch_name_from_stdin(message)
172
176
  branch = ''
173
177
  if @argv['BRANCH'].blank? || (@argv['BRANCH'].present? && !custom_command?)
174
178
  set :app_branch_name, CapistranoMulticonfigParallel.ask_confirm(message, nil)
@@ -178,10 +182,10 @@ module CapistranoMulticonfigParallel
178
182
  end
179
183
  branch
180
184
  end
181
-
185
+
182
186
  def get_app_additional_env_options(app, app_message)
183
187
  app_name = (app.is_a?(Hash) && app[:app].present?) ? app[:app].camelcase : app
184
- app_name = app_name.present? ? app_name : "current application"
188
+ app_name = app_name.present? ? app_name : 'current application'
185
189
  message = "Please write additional ENV options for #{app_name} for #{app_message}"
186
190
  set :app_additional_env_options, CapistranoMulticonfigParallel.ask_confirm(message, nil)
187
191
  fetch_app_additional_env_options