capistrano_sentinel 0.0.12 → 0.0.14

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: 4e4d9c618056cbd81c8dee0e97618556667d96b5
4
- data.tar.gz: ef5b1e1ca9665476e3fdb22d983fcbb9688c32f9
3
+ metadata.gz: 6567c8c26e82b4daaf31af2640ad504455c0aa23
4
+ data.tar.gz: 5eb7391d2aac739c1bfba164650e4fc141dde661
5
5
  SHA512:
6
- metadata.gz: 29c6022aec16df8834decd08a20323b3d79a1bb16ec196d4e5c81f5a387789af8d3aaed4dcaa7a3f9ec9d307d2e50a9e8a3b48655901308fb9e67cab9471623b
7
- data.tar.gz: 8a9bb2c9224d2adb7824029d01dad477a2288e961044a67062f0a59737c98c5c9e23a6a77610cb4b0e0694dd54f0c97d380460087da0233670c00aac2a40fa14
6
+ metadata.gz: f0c0ba51b57e53779ebc8b9f37fe951dfa6c944ba7da17c37500eccca296ca92336f440f0a5056c407b29fbf72994e47338d64eace91fb70ebb7c1ffbc50ca70
7
+ data.tar.gz: 3d836d4404918d23da570ffb417ac1ed121b9e667d8abc0f7bd22ad34d51afb875b76ba846f7eba86d72bf39624c1a97cbc27165de020a32cac5ff8e1fc80e89
data/README.md CHANGED
@@ -72,11 +72,54 @@ Configuration options
72
72
  # if this is enabled, the task will sleep until the socket receives a message back in this format
73
73
  # {"action"=>"invoke", "task"=><task_name>, "job_id"=><job_id>, "approved"=>"yes"},
74
74
  # where the task_name needs to be the task that is waiting for approval and
75
- # the job_id needs to be set using ENV['multi_cap_job_id'], for parallel processing ( if the job id is missing , will be automatically generated with SecureRandom.uuid)
75
+ # the job_id needs to be set using ENV['multi_cap_job_id'], for parallel processing
76
+ # ( if the job id is missing , will be automatically generated with SecureRandom.uuid)
76
77
  config.wait_execution = true
78
+
79
+ # if this is enabled, this will hook into stdin and stdout before a task is executed and if stdin is needed
80
+ # than will publish a message in this format {"action":"stdout","question":"<the stdout message>",default:"", "job_id":"<job_id>" }
81
+ # where question key is done by reading the last message printed by the task and parsing the message to detect
82
+ # if the message is a question . If it is a question in this format ( e.g. "where do you live?(Y/N)")
83
+ # then the question will be sent as "where do you live?" and the default will be "Y/N"
84
+ config.hook_stdin_and_stdout = true
77
85
  end
78
86
  ```
79
87
 
88
+ All websocket messages are published in this format:
89
+
90
+ ```ruby
91
+ {
92
+ "client_action":"publish",
93
+ "channel":"celluloid_worker_<job_id>",
94
+ "data": {}
95
+ }
96
+ ```
97
+
98
+ Where the **data** will have as value the example listed below when using **wait_execution** set to **TRUE**:
99
+
100
+ E.g. Mesage sent before a task is executed:
101
+
102
+ ```ruby
103
+ {
104
+ "action"=> "invoke",
105
+ "task"=> <task_name>,
106
+ "job_id"=> <job_id>
107
+ }
108
+ ```
109
+
110
+ Or when using **hook_stdin_and_stdout** set to **TRUE**:
111
+
112
+ And E.g.
113
+
114
+ ```ruby
115
+ {
116
+ "action": "stdout",
117
+ "question": < if the stdout contains ? or : will use the text before that character >,
118
+ 'default': <if the stdout message cotains () will use the text from within, otherwise string blank >,
119
+ "job_id": "<job_id>"
120
+ }
121
+ ```
122
+
80
123
  Usage Instructions
81
124
  ==================
82
125
 
@@ -1,6 +1,6 @@
1
1
  module CapistranoSentinel
2
2
  class Configuration
3
- SETTINGS = [:host, :port, :path, :secure, :auto_pong, :read_buffer_size,:reconnect, :retry_time, :wait_execution]
3
+ SETTINGS = [:host, :port, :path, :secure, :auto_pong, :read_buffer_size,:reconnect, :retry_time, :wait_execution, :hook_stdin_and_stdout]
4
4
 
5
5
  SETTINGS.each do |setting|
6
6
  attr_reader setting
@@ -17,6 +17,7 @@ module CapistranoSentinel
17
17
  @reconnect = false
18
18
  @retry_time = 0
19
19
  @wait_execution = true
20
+ @hook_stdin_and_stdout = true
20
21
  end
21
22
 
22
23
  def update(settings_hash)
@@ -38,7 +38,7 @@ module CapistranoSentinel
38
38
  end
39
39
 
40
40
  def print_question?(question)
41
- if job_id.present?
41
+ if CapistranoSentinel.config.hook_stdin_and_stdout && job_id.present?
42
42
  actor.user_prompt_needed?(question)
43
43
  else
44
44
  yield if block_given?
@@ -79,9 +79,9 @@ module CapistranoSentinel
79
79
  end
80
80
 
81
81
  def actor_execute_block(&block)
82
- before_hooks
82
+ before_hooks if CapistranoSentinel.config.hook_stdin_and_stdout
83
83
  block.call
84
- after_hooks
84
+ after_hooks if CapistranoSentinel.config.hook_stdin_and_stdout
85
85
  end
86
86
 
87
87
  def actor_start_working(additionals = {})
@@ -92,7 +92,7 @@ module CapistranoSentinel
92
92
  end
93
93
 
94
94
  def stdin_approval(message)
95
- return unless msg_for_stdin?(message)
95
+ return if !CapistranoSentinel.config.wait_execution || !msg_for_stdin?(message)
96
96
  if @job_id == message['job_id']
97
97
  @stdin_result = message.fetch('result', '')
98
98
  else
@@ -101,7 +101,7 @@ module CapistranoSentinel
101
101
  end
102
102
 
103
103
  def task_approval(message)
104
- return if !message_is_about_a_task?(message)
104
+ return if !CapistranoSentinel.config.wait_execution || !message_is_about_a_task?(message)
105
105
  log_to_file("RakeWorker #{@job_id} #{task_name} task_approval : #{message.inspect}")
106
106
  if @job_id.to_s == message['job_id'].to_s && message['task'].to_s == task_name.to_s && message['approved'] == 'yes'
107
107
  @task_approved = true
@@ -17,7 +17,7 @@ module CapistranoSentinel
17
17
  # minor release version
18
18
  MINOR = 0
19
19
  # tiny release version
20
- TINY = 12
20
+ TINY = 14
21
21
  # prelease version ( set this only if it is a prelease)
22
22
  PRE = nil
23
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_sentinel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada