capistrano_sentinel 0.0.15 → 0.0.16

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: 1cc01aa8dc3ee91a8dc14215e8feef1287da0c87
4
- data.tar.gz: 51d882889f47d5996e5be5c8c1581bd902f08037
3
+ metadata.gz: 8b6b182133b14542484ea0826866219fe15b3f4b
4
+ data.tar.gz: e8a7a2543dbf262fc31a313793e601dc190ec95e
5
5
  SHA512:
6
- metadata.gz: e1ec7fe7b1dcc97bdf12447464e3f211d0870da529a5d65fef1dcc0c26f0481fbdadad75328930f40f9e22db9f55f7904a71cf1bf59ddc95fb4dcab5de2c1db5
7
- data.tar.gz: c853ec02a1571d484ab18098e6dfafad1ab29c0723b5a8dbeba7644d624c03efdf081bcaaad13a2b552fcc42ed5307f5cdc3df26f26fe1a8454209f61b630a58
6
+ metadata.gz: 790ea96121af5f8ddda552c560b762da0774239a234da419b3bd2a1a937d729e68e6d3265fb803d429e28ed436d404ae49c501a402cb06c93903717208bf345a
7
+ data.tar.gz: 3a5041ea520987f0d7fcdfaaa55c08f5d598b33bba2bcc23e98df9c0b6b1bd4491cb8448a043496e9623741c5be08bd13137f310c8f82e2f365cb5e63559e72f
data/README.md CHANGED
@@ -3,6 +3,9 @@ capistrano_sentinel
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/capistrano_sentinel.svg)](http://badge.fury.io/rb/capistrano_sentinel) [![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/capistrano_sentinel?type=total&style=dynamic)](https://github.com/bogdanRada/capistrano_sentinel) [![Analytics](https://ga-beacon.appspot.com/UA-72570203-1/bogdanRada/capistrano_sentinel)](https://github.com/bogdanRada/capistrano_sentinel)
5
5
 
6
+ **IMPORTANT!!!** The whole reason for this gem was for using [capistrano_multiconfig_parallel](https://github.com/bogdanRada/capistrano_multiconfig_parallel) that allows you to run tasks in parallel for multiple aplications. This gem is practically the producer that produces the websocket events when a capistrano task is running and the other gem is the consumer that consumes the messages and acts depending on configuration and displays the progress on screen
7
+
8
+
6
9
  Overview
7
10
  --------
8
11
 
@@ -1,6 +1,18 @@
1
1
  module CapistranoSentinel
2
2
  class Configuration
3
- SETTINGS = [:host, :port, :path, :secure, :auto_pong, :read_buffer_size,:reconnect, :retry_time, :wait_execution, :hook_stdin_and_stdout]
3
+
4
+ SETTINGS = [
5
+ :secure,
6
+ :host,
7
+ :port,
8
+ :path,
9
+ :auto_pong,
10
+ :read_buffer_size,
11
+ :reconnect,
12
+ :retry_time,
13
+ :wait_execution,
14
+ :hook_stdin_and_stdout
15
+ ]
4
16
 
5
17
  SETTINGS.each do |setting|
6
18
  attr_reader setting
@@ -20,14 +32,5 @@ module CapistranoSentinel
20
32
  @hook_stdin_and_stdout = true
21
33
  end
22
34
 
23
- def update(settings_hash)
24
- settings_hash.each do |setting, value|
25
- unless SETTINGS.include? setting.to_sym
26
- raise ArgumentError, "invalid setting: #{setting}"
27
- end
28
-
29
- self.public_send "#{setting}=", value
30
- end
31
- end
32
35
  end
33
36
  end
@@ -10,7 +10,18 @@ module CapistranoSentinel
10
10
  end
11
11
 
12
12
  def self.socket_client
13
- @@socket_client ||= CapistranoSentinel::WebsocketClient.new(actor: nil, enable_debug: ENV.fetch('debug_websocket', false), channel: "#{CapistranoSentinel::RequestHooks::SUBSCRIPTION_PREFIX}#{job_id}", log_file_path: ENV.fetch('websocket_log_file_path', nil))
13
+ @@socket_client ||= CapistranoSentinel::WebsocketClient.new(
14
+ actor: nil,
15
+ channel: "#{CapistranoSentinel::RequestHooks::SUBSCRIPTION_PREFIX}#{job_id}",
16
+ auto_pong: ENV.fetch('WS_AUTO_PONG', nil),
17
+ read_buffer_size: ENV.fetch('WS_READ_BUFFER_SIZE', nil),
18
+ reconnect: ENV.fetch("WS_RECONNECT", nil),
19
+ retry_time: ENV.fetch("WS_RETRY_TIME", nil),
20
+ secure: ENV.fetch("WS_SECURE", nil),
21
+ host: ENV.fetch("WS_HOST", nil),
22
+ port: ENV.fetch("WS_PORT", nil),
23
+ path: ENV.fetch("WS_PATH", nil)
24
+ )
14
25
  end
15
26
 
16
27
  ENV_KEY_JOB_ID = 'multi_cap_job_id'
@@ -29,7 +40,9 @@ module CapistranoSentinel
29
40
  subscribed_already = defined?(@@socket_client)
30
41
  actor_start_working(action: 'invoke', subscribed: subscribed_already)
31
42
  if CapistranoSentinel.config.wait_execution
32
- actor.wait_execution until actor.task_approved
43
+ actor.wait_execution_of_task until actor.task_approved
44
+ elsif subscribed_already.blank?
45
+ actor.wait_execution_of_task until actor.successfull_subscription
33
46
  end
34
47
  actor_execute_block(&block)
35
48
  else
@@ -6,17 +6,17 @@ module CapistranoSentinel
6
6
  include CapistranoSentinel::ApplicationHelper
7
7
 
8
8
  attr_reader :client, :job_id, :action, :task,
9
- :task_approved, :stdin_result, :executor
9
+ :task_approved, :stdin_result, :executor, :successfull_subscription
10
10
 
11
11
 
12
12
  def work(options = {})
13
13
  @options = options.stringify_keys
14
14
  default_settings
15
15
  socket_client.actor = self
16
- publish_to_worker(task_data) if CapistranoSentinel.config.wait_execution && options['subscribed'].present?
16
+ publish_to_worker(task_data) if options['subscribed'].present?
17
17
  end
18
18
 
19
- def wait_execution(name = task_name, time = 0.1)
19
+ def wait_execution_of_task(name = task_name, time = 0.1)
20
20
  # info "Before waiting #{name}"
21
21
  wait_for(name, time)
22
22
  # info "After waiting #{name}"
@@ -38,6 +38,7 @@ module CapistranoSentinel
38
38
  @task_approved = false
39
39
  @action = @options['action'].present? ? @options['action'] : 'invoke'
40
40
  @task = @options['task']
41
+ @successfull_subscription = false
41
42
  end
42
43
 
43
44
  def task_name
@@ -80,12 +81,12 @@ module CapistranoSentinel
80
81
  def publish_subscription_successfull(message)
81
82
  return unless message['client_action'] == 'successful_subscription'
82
83
  log_to_file("Rake worker #{@job_id} received after publish_subscription_successfull: #{message}")
83
- @successfull_subscription = true
84
84
  publish_to_worker(task_data)
85
+ @successfull_subscription = true
85
86
  end
86
87
 
87
88
  def wait_for_stdin_input
88
- wait_execution until @stdin_result.present?
89
+ wait_execution_of_task until @stdin_result.present?
89
90
  output = @stdin_result.clone
90
91
  @stdin_result = nil
91
92
  output
@@ -84,6 +84,7 @@ module CapistranoSentinel
84
84
  message = parse_json(message)
85
85
  log_to_file("#{@actor.class} websocket client received JSON #{message}")
86
86
  if @actor.present? && @actor.respond_to?(:async)
87
+ log_to_file("#{@actor.class} works async on message #{message.inspect}")
87
88
  @actor.async.on_message(message)
88
89
  else
89
90
  @actor.on_message(message)
@@ -104,7 +105,7 @@ module CapistranoSentinel
104
105
  #
105
106
  # @api public
106
107
  def subscribe(channel, data = {})
107
- log_to_file("#{self.class} tries to subscribe to channel #{channel}")
108
+ log_to_file("#{self.class} tries to subscribe to channel #{channel} with #{data.inspect}")
108
109
  send_action('subscribe', channel, data)
109
110
  end
110
111
 
@@ -188,7 +189,6 @@ module CapistranoSentinel
188
189
  #+type+:: :text or :binary, defaults to :text
189
190
  def send_data(data, type = :text)
190
191
  pid = Thread.new do
191
- log_to_file("#{@actor.class} calls send: #{data}")
192
192
  do_send(data, type)
193
193
  end
194
194
  end
@@ -17,7 +17,7 @@ module CapistranoSentinel
17
17
  # minor release version
18
18
  MINOR = 0
19
19
  # tiny release version
20
- TINY = 15
20
+ TINY = 16
21
21
  # prelease version ( set this only if it is a prelease)
22
22
  PRE = nil
23
23
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_sentinel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket