capistrano_sentinel 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/capistrano_sentinel/all.rb +8 -5
- data/lib/capistrano_sentinel/classes/request_worker.rb +2 -4
- data/lib/capistrano_sentinel/classes/websocket_client.rb +33 -10
- data/lib/capistrano_sentinel/version.rb +1 -1
- metadata +2 -3
- data/lib/capistrano_sentinel/helpers/actor.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7281ef91ca49872bf389712c641d09a18d4b9ef5
|
4
|
+
data.tar.gz: ad67df5a0f82502974869c386e95f99b77e935d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c8fc536eb801158032d5351a38e509eebb0f2a4c6cf50d222ad513479e0e159f412ef4a987b66082ad9c38b676dfb735e203607d533aec6a54efa1e096a5e4e
|
7
|
+
data.tar.gz: 565e21233c9bac28bf32ef25d216b529cf019a21d1b44c057d47abd882c7d47f83873238b503cf8d88f5dae87ae2a24117b5e71a0a0e38de332e0560ede50ce7
|
@@ -21,10 +21,13 @@ require_relative './classes/gem_finder'
|
|
21
21
|
Gem.find_files("#{CapistranoSentinel::GemFinder.get_current_gem_name}/#{folder_name}/**/*.rb").each { |path| require path }
|
22
22
|
end
|
23
23
|
|
24
|
-
if !CapistranoSentinel::GemFinder.value_blank?(ENV[CapistranoSentinel::RequestHooks::ENV_KEY_JOB_ID])
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
if !CapistranoSentinel::GemFinder.value_blank?(ENV[CapistranoSentinel::RequestHooks::ENV_KEY_JOB_ID])
|
25
|
+
|
26
|
+
if CapistranoSentinel::GemFinder.fetch_gem_version('capistrano')
|
27
|
+
if CapistranoSentinel::GemFinder.capistrano_version_2?
|
28
|
+
require_relative './patches/capistrano2'
|
29
|
+
else
|
30
|
+
require_relative './patches/rake'
|
31
|
+
end
|
29
32
|
end
|
30
33
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
require_relative '../helpers/actor'
|
2
1
|
require_relative './websocket_client'
|
3
2
|
require_relative '../helpers/application_helper'
|
4
3
|
module CapistranoSentinel
|
5
4
|
# class that handles the rake task and waits for approval from the celluloid worker
|
6
5
|
class RequestWorker
|
7
6
|
include CapistranoSentinel::ApplicationHelper
|
8
|
-
#include CapistranoSentinel::Actor
|
9
7
|
|
10
8
|
attr_reader :client, :job_id, :action, :task,
|
11
9
|
:task_approved, :stdin_result, :executor
|
@@ -103,10 +101,10 @@ module CapistranoSentinel
|
|
103
101
|
def task_approval(message)
|
104
102
|
return if !message_is_about_a_task?(message)
|
105
103
|
log_to_file("RakeWorker #{@job_id} #{task_name} task_approval : #{message.inspect}")
|
106
|
-
if @job_id == message['job_id'] && message['task']
|
104
|
+
if @job_id.to_s == message['job_id'].to_s && message['task'] && message['approved'] == 'yes'
|
107
105
|
@task_approved = true
|
108
106
|
else
|
109
|
-
show_warning "unknown task_approval #{message
|
107
|
+
show_warning "unknown task_approval #{message} #{task_data}"
|
110
108
|
end
|
111
109
|
end
|
112
110
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require_relative './websocket/errors'
|
2
|
-
require_relative '../helpers/actor'
|
3
2
|
require_relative '../helpers/application_helper'
|
4
3
|
module CapistranoSentinel
|
5
4
|
class WebsocketClient
|
6
|
-
include CapistranoSentinel::AsyncActor
|
7
5
|
include CapistranoSentinel::ApplicationHelper
|
8
6
|
|
9
7
|
HOST = '0.0.0.0'
|
@@ -46,34 +44,59 @@ module CapistranoSentinel
|
|
46
44
|
@channel ||= @options.fetch(:channel, nil)
|
47
45
|
raise "#{self}: Please provide an actor in the options list!!!" if @actor.blank?
|
48
46
|
|
47
|
+
|
49
48
|
@auto_pong = @options.fetch(:auto_pong, true) || true
|
50
49
|
@closed = false
|
51
50
|
@opened = false
|
52
51
|
|
53
52
|
@on_open = lambda {
|
54
|
-
log_to_file("
|
53
|
+
log_to_file("native websocket client websocket connection opened")
|
55
54
|
subscribe(@channel) if @channel.present?
|
56
55
|
}
|
57
56
|
|
58
57
|
@on_close = lambda { |message|
|
59
|
-
log_to_file("
|
60
|
-
@actor.on_close
|
58
|
+
log_to_file("native websocket client received on_close #{message.inspect}")
|
59
|
+
if @actor.respond_to?(:on_close)
|
60
|
+
if @actor.respond_to?(:async)
|
61
|
+
@actor.async.on_close(message)
|
62
|
+
else
|
63
|
+
@actor.on_close(message)
|
64
|
+
end
|
65
|
+
end
|
61
66
|
}
|
62
67
|
|
63
68
|
@on_ping = lambda { |message|
|
64
|
-
|
69
|
+
log_to_file("native websocket client received PING #{message.inspect}")
|
70
|
+
if @actor.respond_to?(:on_ping)
|
71
|
+
if @actor.respond_to?(:async)
|
72
|
+
@actor.async.on_ping(message)
|
73
|
+
else
|
74
|
+
@actor.on_ping(message)
|
75
|
+
end
|
76
|
+
end
|
65
77
|
}
|
66
78
|
|
67
79
|
@on_error = lambda { |error|
|
68
|
-
|
80
|
+
log_to_file("native websocket client received ERROR #{error.inspect} #{error.backtrace}")
|
81
|
+
if @actor.respond_to?(:on_error)
|
82
|
+
if @actor.respond_to?(:async)
|
83
|
+
@actor.async.on_error(error)
|
84
|
+
else
|
85
|
+
@actor.on_error(error)
|
86
|
+
end
|
87
|
+
end
|
69
88
|
}
|
70
89
|
|
71
90
|
@on_message = lambda { |message|
|
72
91
|
message = parse_json(message)
|
73
|
-
log_to_file("
|
74
|
-
@actor.
|
92
|
+
log_to_file("native websocket client received JSON #{message}")
|
93
|
+
if @actor.respond_to?(:async)
|
94
|
+
@actor.async.on_message(message)
|
95
|
+
else
|
96
|
+
@actor.on_message(message)
|
97
|
+
end
|
75
98
|
}
|
76
|
-
|
99
|
+
connect
|
77
100
|
end
|
78
101
|
|
79
102
|
def is_windows?
|
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.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- lib/capistrano_sentinel/classes/request_worker.rb
|
46
46
|
- lib/capistrano_sentinel/classes/websocket/errors.rb
|
47
47
|
- lib/capistrano_sentinel/classes/websocket_client.rb
|
48
|
-
- lib/capistrano_sentinel/helpers/actor.rb
|
49
48
|
- lib/capistrano_sentinel/helpers/application_helper.rb
|
50
49
|
- lib/capistrano_sentinel/helpers/logging.rb
|
51
50
|
- lib/capistrano_sentinel/initializers/active_support/blank.rb
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require_relative './application_helper'
|
2
|
-
module CapistranoSentinel
|
3
|
-
module AsyncActor
|
4
|
-
include CapistranoSentinel::ApplicationHelper
|
5
|
-
|
6
|
-
Context = Struct.new(:method, :args, :block)
|
7
|
-
|
8
|
-
Async = Struct.new(:instance, :mailbox) do
|
9
|
-
extend Forwardable
|
10
|
-
def_delegator :instance, :respond_to?
|
11
|
-
|
12
|
-
private :instance
|
13
|
-
private :mailbox
|
14
|
-
|
15
|
-
def initialize(instance, mailbox)
|
16
|
-
super(instance, mailbox)
|
17
|
-
run!
|
18
|
-
end
|
19
|
-
|
20
|
-
def method_missing(method, *args, &block)
|
21
|
-
mailbox << CapistranoSentinel::AsyncActor::Context.new(method, args, block)
|
22
|
-
nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def run!
|
29
|
-
Thread.new do
|
30
|
-
loop do
|
31
|
-
break if mailbox.empty?
|
32
|
-
begin
|
33
|
-
mailbox.synchronize do
|
34
|
-
ctx = mailbox.pop
|
35
|
-
instance.public_send(ctx.method, *ctx.args, &ctx.block)
|
36
|
-
end
|
37
|
-
rescue => e
|
38
|
-
log_to_file("crashed with #{e.inspect} #{e.backtrace}")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def async_queue
|
45
|
-
@async_queue ||= Queue.new.extend(MonitorMixin)
|
46
|
-
end
|
47
|
-
|
48
|
-
def async
|
49
|
-
@async ||= CapistranoSentinel::AsyncActor::Async.new(self, async_queue)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|