capistrano_multiconfig_parallel 1.1.9 → 1.2.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: d81f344d7242ec416e171393c6bdc5cee38b75ce
4
- data.tar.gz: 2daf07ef4b0f0141de876309c765695ab4c067f9
3
+ metadata.gz: 1e4d9a28f5d3cdeb1e98c18c651ec36cd83c6cec
4
+ data.tar.gz: b311f2acada696e6e029fdeebbded2fd868c228d
5
5
  SHA512:
6
- metadata.gz: 253acf6fc8f334b79e4aa1fe5c20a5fc9132b31babc0ddd4ae5b79938d39cffae4c97cca3dc44891cc99e9f96b814c3e6da015c7152b9bcbd834c884e119b7ce
7
- data.tar.gz: 7330d539c6db97a9c0e417b2177261e6a9900c3a4476f17ad12b7224e935a03978087b940c1cb5e1719f056e155e470668df96dc08bfadd203065c715b38812f
6
+ metadata.gz: 4c0e34c2a8e00ad86845bb2d8d2b51ab412766b9632e193467d906c1fb8bfb6da06072d6304fccf9d24d2e05b1aabf81d27ba6ac9f6129285dc6add29a28a31f
7
+ data.tar.gz: 66b76ce6cf78619cf93a58ff9ef237f1c6f2347ba949566dba1b63ff1cac72318ee91d8e791acc7c34e7332ca6a287d00b28c8f05cdbebf288f8ec683af5e7a1
data/README.md CHANGED
@@ -17,6 +17,11 @@ 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
+ ---------------------------------
22
+
23
+ - support for Celluloid 0.17 was added
24
+
20
25
  NEW Improvements in version 1.1.0
21
26
  ---------------------------------
22
27
 
@@ -17,6 +17,7 @@ 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
21
  s.add_runtime_dependency 'celluloid-pmap', '~> 0.2', '>= 0.2.2'
21
22
  s.add_runtime_dependency 'celluloid_pubsub', '~> 0.6', '>= 0.6.1'
22
23
  s.add_runtime_dependency 'celluloid-websocket-client', '~> 0.0', '>= 0.0.1'
@@ -7,15 +7,15 @@ require 'active_support/core_ext/hash/keys'
7
7
  require 'active_support/core_ext/module/delegation'
8
8
  require 'active_support/concern'
9
9
 
10
- require 'celluloid/autostart'
10
+ require_relative './helpers/base_actor_helper'
11
11
  require 'celluloid/pmap'
12
+ require 'celluloid_pubsub'
12
13
 
13
14
  require 'composable_state_machine'
14
15
  require 'eventmachine'
15
16
  require 'right_popen'
16
17
  require 'colorize'
17
18
  require 'terminal-table'
18
- require 'celluloid_pubsub'
19
19
  require 'configliere'
20
20
  require 'devnull'
21
21
  require 'inquirer'
@@ -1,14 +1,13 @@
1
+ require_relative './helpers/base_actor_helper'
1
2
  module CapistranoMulticonfigParallel
2
3
  # finds app dependencies, shows menu and delegates jobs to celluloid manager
3
4
  class Application
4
- include Celluloid
5
- include Celluloid::Logger
6
- include CapistranoMulticonfigParallel::ApplicationHelper
5
+ include CapistranoMulticonfigParallel::BaseActorHelper
7
6
 
8
7
  attr_reader :stage_apps, :top_level_tasks, :jobs, :condition, :manager, :dependency_tracker, :application, :stage, :name, :args, :argv, :default_stage
9
8
 
10
9
  def initialize
11
- Celluloid.boot
10
+ Celluloid.boot unless Celluloid.running?
12
11
  CapistranoMulticonfigParallel.enable_logging
13
12
  @stage_apps = multi_apps? ? app_names_from_stages : []
14
13
  collect_command_line_tasks(CapistranoMulticonfigParallel.original_args)
@@ -1,15 +1,11 @@
1
1
  require_relative './celluloid_worker'
2
2
  require_relative './terminal_table'
3
3
  require_relative './web_server'
4
- require_relative '../helpers/application_helper'
4
+ require_relative '../helpers/base_actor_helper'
5
5
  module CapistranoMulticonfigParallel
6
6
  # manager class that handles workers
7
7
  class CelluloidManager
8
- include Celluloid
9
- include Celluloid::Notifications
10
- include Celluloid::Logger
11
- include CapistranoMulticonfigParallel::ApplicationHelper
12
-
8
+ include CapistranoMulticonfigParallel::BaseActorHelper
13
9
  attr_accessor :jobs, :job_to_worker, :worker_to_job, :job_to_condition, :mutex, :registration_complete, :workers_terminated, :stderr_buffer
14
10
 
15
11
  attr_reader :worker_supervisor, :workers
@@ -20,16 +16,16 @@ module CapistranoMulticonfigParallel
20
16
  @registration_complete = false
21
17
  return if configuration.multi_secvential.to_s.downcase == 'true'
22
18
  # start SupervisionGroup
23
- @worker_supervisor = Celluloid::SupervisionGroup.run!
19
+ @worker_supervisor = setup_supervision_group
24
20
 
25
21
  # Get a handle on the SupervisionGroup::Member
26
22
  @mutex = Mutex.new
27
23
  # http://rubydoc.info/gems/celluloid/Celluloid/SupervisionGroup/Member
28
- @workers = @worker_supervisor.pool(CapistranoMulticonfigParallel::CelluloidWorker, as: :workers, size: 10)
24
+ @workers = setup_pool_of_actor(@worker_supervisor, actor_name: :workers, type: CapistranoMulticonfigParallel::CelluloidWorker, size: 10)
29
25
  Actor.current.link @workers
30
- @worker_supervisor.supervise_as(:terminal_server, CapistranoMulticonfigParallel::TerminalTable, Actor.current, @job_manager, configuration.fetch(:terminal, {}))
31
- @worker_supervisor.supervise_as(:web_server, CapistranoMulticonfigParallel::WebServer, [websocket_config])
32
-
26
+ setup_actor_supervision(@worker_supervisor, actor_name: :terminal_server, type: CapistranoMulticonfigParallel::TerminalTable, args: [Actor.current, @job_manager, configuration.fetch(:terminal, {})])
27
+ setup_actor_supervision(@worker_supervisor, actor_name: :web_server, type: CapistranoMulticonfigParallel::WebServer, args: websocket_config)
28
+
33
29
  # Get a handle on the PoolManager
34
30
  # http://rubydoc.info/gems/celluloid/Celluloid/PoolManager
35
31
  # @workers = workers_pool.actor
@@ -1,6 +1,6 @@
1
1
  require_relative './child_process'
2
2
  require_relative './state_machine'
3
- require_relative '../helpers/application_helper'
3
+ require_relative '../helpers/base_actor_helper'
4
4
  module CapistranoMulticonfigParallel
5
5
  # worker that will spawn a child process in order to execute a capistrano job and monitor that process
6
6
  #
@@ -17,10 +17,7 @@ module CapistranoMulticonfigParallel
17
17
  # @return [CapistranoMulticonfigParallel::CelluloidManager] the instance of the manager that delegated the job to this worker
18
18
  #
19
19
  class CelluloidWorker
20
- include Celluloid
21
- include Celluloid::Notifications
22
- include Celluloid::Logger
23
- include CapistranoMulticonfigParallel::ApplicationHelper
20
+ include CapistranoMulticonfigParallel::BaseActorHelper
24
21
  class TaskFailed < StandardError; end
25
22
 
26
23
  attr_accessor :job, :manager, :job_id, :app_name, :env_name, :action_name, :env_options, :machine, :client, :task_argv,
@@ -1,11 +1,8 @@
1
- require_relative '../helpers/application_helper'
2
- require_relative '../helpers/core_helper'
1
+ require_relative '../helpers/base_actor_helper'
3
2
  module CapistranoMulticonfigParallel
4
3
  # class that is used to execute the capistrano tasks and it is invoked by the celluloid worker
5
4
  class ChildProcess
6
- include Celluloid
7
- include Celluloid::Logger
8
- include CapistranoMulticonfigParallel::ApplicationHelper
5
+ include CapistranoMulticonfigParallel::BaseActorHelper
9
6
 
10
7
  attr_accessor :options, :job, :actor, :job_id, :exit_status, :pid, :process
11
8
 
@@ -1,10 +1,8 @@
1
- require_relative '../helpers/application_helper'
1
+ require_relative '../helpers/base_actor_helper'
2
2
  module CapistranoMulticonfigParallel
3
3
  # class that handles the rake task and waits for approval from the celluloid worker
4
4
  class RakeWorker
5
- include Celluloid
6
- include Celluloid::Logger
7
- include CapistranoMulticonfigParallel::ApplicationHelper
5
+ include CapistranoMulticonfigParallel::BaseActorHelper
8
6
 
9
7
  attr_reader :client, :job_id, :action, :task,
10
8
  :task_approved, :successfull_subscription,
@@ -1,12 +1,9 @@
1
1
 
2
- require_relative '../helpers/application_helper'
2
+ require_relative '../helpers/base_actor_helper'
3
3
  module CapistranoMulticonfigParallel
4
4
  # class used to display the progress of each worker on terminal screen using a table
5
5
  class TerminalTable
6
- include Celluloid
7
- include Celluloid::Notifications
8
- include Celluloid::Logger
9
- include CapistranoMulticonfigParallel::ApplicationHelper
6
+ include CapistranoMulticonfigParallel::BaseActorHelper
10
7
 
11
8
  attr_reader :options, :errors, :manager, :position, :job_manager, :terminal_rows, :screen_erased
12
9
 
@@ -0,0 +1,84 @@
1
+ require_relative '../helpers/application_helper'
2
+ module CapistranoMulticonfigParallel
3
+ # base actor used for compatibility between celluloid versions
4
+ module BaseActorHelper
5
+
6
+ module ClassMethods
7
+ class << self
8
+ include CapistranoMulticonfigParallel::ApplicationHelper
9
+ attr_reader :config
10
+
11
+
12
+ def config
13
+ {
14
+ 'logger_class' => celluloid_logger_class
15
+ }
16
+ end
17
+
18
+ def celluloid_logger_class
19
+ if version_less_than_seventeen?
20
+ Celluloid::Logger
21
+ else
22
+ Celluloid::Internals::Logger
23
+ end
24
+ end
25
+
26
+ def celluloid_version
27
+ find_loaded_gem_property('celluloid', 'version')
28
+ end
29
+
30
+ def version_less_than_seventeen?
31
+ verify_gem_version('celluloid', '0.17', operator: '<')
32
+ end
33
+ end
34
+ end
35
+
36
+ module InstanceMethods
37
+ delegate :version_less_than_seventeen?,
38
+ to: :'CapistranoMulticonfigParallel::BaseActorHelper::ClassMethods'
39
+
40
+ def setup_actor_supervision(class_name, options)
41
+ arguments = options[:args].is_a?(Array) ? options[:args] : [options[:args]]
42
+ if version_less_than_seventeen?
43
+ class_name.supervise_as(options[:actor_name], options[:type], *arguments)
44
+ else
45
+ #supervises_opts = options[:supervises].present? ? { supervises: options[:supervises] } : {}
46
+ default_opts = options[:actor_name].present? ? { as: options[:actor_name], type: options[:type], args: arguments, size: options.fetch(:size, nil) } : {}
47
+ class_name.supervise(default_opts)
48
+ end
49
+ end
50
+
51
+ def setup_supervision_group
52
+ if version_less_than_seventeen?
53
+ Celluloid::SupervisionGroup.run!
54
+ else
55
+ Celluloid::Supervision::Container.run!
56
+ end
57
+ end
58
+
59
+ def setup_pool_of_actor(class_name, options)
60
+ if version_less_than_seventeen?
61
+ class_name.pool(options[:type], as: options[:actor_name], size: options.fetch(:size, 10))
62
+ else
63
+ setup_actor_supervision(class_name, options)
64
+ end
65
+ end
66
+ end
67
+
68
+
69
+ def self.included(base)
70
+ base.include Celluloid
71
+ base.include Celluloid::Notifications
72
+ base.include CapistranoMulticonfigParallel::ApplicationHelper
73
+ base.include CapistranoMulticonfigParallel::BaseActorHelper::ClassMethods.config['logger_class']
74
+ base.include CapistranoMulticonfigParallel::BaseActorHelper::InstanceMethods
75
+ end
76
+
77
+ end
78
+ end
79
+
80
+ if CapistranoMulticonfigParallel::BaseActorHelper::ClassMethods.version_less_than_seventeen?
81
+ require 'celluloid/autostart'
82
+ else
83
+ require 'celluloid/current'
84
+ end
@@ -20,10 +20,16 @@ module CapistranoMulticonfigParallel
20
20
  def get_parsed_version(version)
21
21
  return 0 if version.blank?
22
22
  version = version.to_s.split('.')
23
- version.pop until version.size == 2
23
+ version = format_gem_version(version)
24
24
  version.join('.').to_f
25
25
  end
26
26
 
27
+ def format_gem_version(version)
28
+ return version if version.size <= 2
29
+ version.pop until version.size == 2
30
+ version
31
+ end
32
+
27
33
  def verify_gem_version(gem_version, version, options = {})
28
34
  options.stringify_keys!
29
35
  version = get_parsed_version(version)
@@ -7,8 +7,8 @@ module CapistranoMulticonfigParallel
7
7
  # module used for generating the version
8
8
  module VERSION
9
9
  MAJOR = 1
10
- MINOR = 1
11
- TINY = 9
10
+ MINOR = 2
11
+ TINY = 0
12
12
  PRE = nil
13
13
 
14
14
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_multiconfig_parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
@@ -10,6 +10,26 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: celluloid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.16'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.16.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.16'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.16.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: celluloid-pmap
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -527,6 +547,7 @@ files:
527
547
  - lib/capistrano_multiconfig_parallel/cli.rb
528
548
  - lib/capistrano_multiconfig_parallel/configuration/default.yml
529
549
  - lib/capistrano_multiconfig_parallel/helpers/application_helper.rb
550
+ - lib/capistrano_multiconfig_parallel/helpers/base_actor_helper.rb
530
551
  - lib/capistrano_multiconfig_parallel/helpers/capistrano_helper.rb
531
552
  - lib/capistrano_multiconfig_parallel/helpers/configuration.rb
532
553
  - lib/capistrano_multiconfig_parallel/helpers/core_helper.rb