rookout 0.1.3 → 0.1.8
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/Rakefile +92 -0
- data/ext/mkrf_conf.rb +23 -0
- data/lib/rookout/atfork.rb +73 -0
- data/lib/rookout/augs/aug.rb +2 -1
- data/lib/rookout/com_ws/agent_com_ws.rb +17 -6
- data/lib/rookout/exceptions.rb +1 -1
- data/lib/rookout/interface.rb +12 -5
- data/lib/rookout/processor/namespaces/frame_namespace.rb +1 -0
- data/lib/rookout/processor/namespaces/ruby_object_serializer.rb +1 -0
- data/lib/rookout/rookout_singleton.rb +16 -1
- data/lib/rookout/services/position.rb +3 -3
- data/lib/rookout/version.rb +1 -1
- data/rookout.gemspec +39 -0
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e07553e631fcf24cda02a212f87ded60d516f649efe6f610917071e8db7af7e
|
4
|
+
data.tar.gz: 3fecac876939f846a4e98c00956fef5aaba247944e90fb46a03b495316c7759c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcbc6c8640299f43aaab4cd161200f3454260593839ee8e11c5d593066b65a529410af18ce161e1b5530f8e2d2035c1084998238880314a7ba671ae4d25c09b8
|
7
|
+
data.tar.gz: 8a1d38bae4157be95db520e8195de09938ea25acd5dd8ddbcb1a9b687123c8847e45ff6024ce8920408138986ce34386f010a127dec17e3aa3d615df197142af
|
data/Rakefile
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
spec = Gem::Specification.load("rookout.gemspec")
|
5
|
+
|
6
|
+
require "rake/testtask"
|
7
|
+
desc "Run tests."
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.pattern = "test/**/*_test.rb"
|
10
|
+
t.warning = false
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Run the CI build"
|
14
|
+
task :ci do
|
15
|
+
header "BUILDING rookout", "#"
|
16
|
+
header "rookout rubocop", "*"
|
17
|
+
require "rubocop/rake_task"
|
18
|
+
RuboCop::RakeTask.new
|
19
|
+
Rake::Task[:rubocop].invoke
|
20
|
+
header "rookout test", "*"
|
21
|
+
Rake::Task[:test].invoke
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Set commit hash"
|
25
|
+
task :set_commit do
|
26
|
+
header "Setting commit hash in file", "#"
|
27
|
+
write_commit_file read_commit
|
28
|
+
puts "Done!"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Bump gem vesrion"
|
32
|
+
task :bump_version do
|
33
|
+
header "Bumpding version", "#"
|
34
|
+
|
35
|
+
version = read_version
|
36
|
+
minor_version = version[0...version.rindex(".")]
|
37
|
+
patch_version = version[version.rindex(".") + 1...version.length]
|
38
|
+
new_patch_version = patch_version.to_i + 1
|
39
|
+
new_version = "#{minor_version}.#{new_patch_version}"
|
40
|
+
|
41
|
+
write_version_file new_version
|
42
|
+
|
43
|
+
puts "Done! New version is #{new_version}"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Print version configuration"
|
47
|
+
task :print_version do
|
48
|
+
puts "export ROOK_VERSION=#{read_version}"
|
49
|
+
puts "export ROOK_COMMIT=#{read_commit}"
|
50
|
+
end
|
51
|
+
|
52
|
+
task :default => :test
|
53
|
+
|
54
|
+
def read_version
|
55
|
+
require_relative "lib/rookout/version"
|
56
|
+
Rookout::VERSION
|
57
|
+
end
|
58
|
+
|
59
|
+
def read_commit
|
60
|
+
`git rev-parse HEAD`.strip
|
61
|
+
end
|
62
|
+
|
63
|
+
def write_version_file new_version
|
64
|
+
contents = ""
|
65
|
+
contents += "module Rookout\n"
|
66
|
+
contents += " VERSION = \"#{new_version}\".freeze\n"
|
67
|
+
contents += "end\n"
|
68
|
+
|
69
|
+
f = File.new "lib/rookout/version.rb", "wb"
|
70
|
+
f.write contents
|
71
|
+
f.close
|
72
|
+
end
|
73
|
+
|
74
|
+
def write_commit_file commit
|
75
|
+
contents = ""
|
76
|
+
contents += "module Rookout\n"
|
77
|
+
contents += " COMMIT = \"#{commit}\".freeze\n"
|
78
|
+
contents += "end\n"
|
79
|
+
|
80
|
+
f = File.new "lib/rookout/commit.rb", "wb"
|
81
|
+
f.write contents
|
82
|
+
f.close
|
83
|
+
end
|
84
|
+
|
85
|
+
def header str, token
|
86
|
+
line_length = str.length + 8
|
87
|
+
puts ""
|
88
|
+
puts token * line_length
|
89
|
+
puts "#{token * 3} #{str} #{token * 3}"
|
90
|
+
puts token * line_length
|
91
|
+
puts ""
|
92
|
+
end
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rubygems/command.rb"
|
3
|
+
require "rubygems/dependency_installer.rb"
|
4
|
+
|
5
|
+
# We override platform comparison to only match source gems
|
6
|
+
class Gem::Platform
|
7
|
+
def self.match platform
|
8
|
+
platform.nil? || platform == Gem::Platform::RUBY
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
inst = Gem::DependencyInstaller.new
|
13
|
+
begin
|
14
|
+
puts "[Rookout] installing appropriate google-protobuf gem"
|
15
|
+
if File.exist? "/etc/alpine-release"
|
16
|
+
installed = inst.install "google-protobuf", [">= 3.0.0", "< 3.10.0"]
|
17
|
+
else
|
18
|
+
installed = inst.install "google-protobuf", ">= 3.0.0"
|
19
|
+
end
|
20
|
+
puts "[Rookout] Installed additional dependencies: #{installed}"
|
21
|
+
rescue
|
22
|
+
exit 1
|
23
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Rookout
|
2
|
+
class ForkManager
|
3
|
+
require "singleton"
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@active = false
|
8
|
+
end
|
9
|
+
|
10
|
+
def activate!
|
11
|
+
@active = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def disable!
|
15
|
+
@active = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def active?
|
19
|
+
@active
|
20
|
+
end
|
21
|
+
|
22
|
+
def fork_hook original_fork
|
23
|
+
if block_given?
|
24
|
+
original_fork.call do
|
25
|
+
post_fork_child if active?
|
26
|
+
yield
|
27
|
+
end
|
28
|
+
else
|
29
|
+
res = original_fork.call
|
30
|
+
post_fork_child if active? && !res
|
31
|
+
res
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def post_fork_child
|
36
|
+
require_relative "rookout_singleton"
|
37
|
+
require_relative "interface"
|
38
|
+
|
39
|
+
RookoutSingleton.instance.post_fork_clean
|
40
|
+
Interface.instance.stop
|
41
|
+
Interface.instance.start post_fork: true
|
42
|
+
|
43
|
+
# Disable fork handler in child process
|
44
|
+
disable!
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
alias _rookout_original_fork fork
|
50
|
+
|
51
|
+
def self.fork &block
|
52
|
+
Rookout::ForkManager.instance.fork_hook method(:_rookout_original_fork), &block
|
53
|
+
end
|
54
|
+
|
55
|
+
def fork &block
|
56
|
+
Rookout::ForkManager.instance.fork_hook method(:_rookout_original_fork), &block
|
57
|
+
end
|
58
|
+
|
59
|
+
module Kernel
|
60
|
+
alias _rookout_original_fork fork
|
61
|
+
|
62
|
+
def self.fork &block
|
63
|
+
Rookout::ForkManager.instance.fork_hook method(:_rookout_original_fork), &block
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
module Process
|
68
|
+
alias _rookout_original_fork fork
|
69
|
+
|
70
|
+
def self.fork &block
|
71
|
+
Rookout::ForkManager.instance.fork_hook method(:_rookout_original_fork), &block
|
72
|
+
end
|
73
|
+
end
|
data/lib/rookout/augs/aug.rb
CHANGED
@@ -46,7 +46,8 @@ module Rookout
|
|
46
46
|
"store" => Processor::Namespaces::ContainerNamespace.new,
|
47
47
|
"temp" => Processor::Namespaces::ContainerNamespace.new,
|
48
48
|
"utils" => Processor::Namespaces::RubyUtilsNamespace.new,
|
49
|
-
"trace" => Processor::Namespaces::NoopNamespace.new
|
49
|
+
"trace" => Processor::Namespaces::NoopNamespace.new,
|
50
|
+
"state" => Processor::Namespaces::NoopNamespace.new
|
50
51
|
)
|
51
52
|
end
|
52
53
|
end
|
@@ -39,7 +39,8 @@ module Rookout
|
|
39
39
|
@info = Information.new labels
|
40
40
|
reset_id
|
41
41
|
|
42
|
-
@
|
42
|
+
@main_thread = nil
|
43
|
+
@outgoing_thread = nil
|
43
44
|
@pending_messages = Queue.new
|
44
45
|
|
45
46
|
@running = false
|
@@ -64,8 +65,17 @@ module Rookout
|
|
64
65
|
def connect
|
65
66
|
@running = true
|
66
67
|
|
67
|
-
@
|
68
|
-
@
|
68
|
+
@main_thread = Thread.new { connection_thread }
|
69
|
+
@main_thread.name = "rookout-connection-thread"
|
70
|
+
end
|
71
|
+
|
72
|
+
def stop
|
73
|
+
@running = false
|
74
|
+
|
75
|
+
# Ask outgoing thread to exit (if running)
|
76
|
+
@pending_messages << ExitMessage.new(@outgoing_thread)
|
77
|
+
|
78
|
+
@main_thread.join
|
69
79
|
end
|
70
80
|
|
71
81
|
def wait_for_ready
|
@@ -133,8 +143,8 @@ module Rookout
|
|
133
143
|
|
134
144
|
def connection_pump client
|
135
145
|
on_outgoing_exit = proc { client.close }
|
136
|
-
|
137
|
-
|
146
|
+
@outgoing_thread = Thread.new { outgoing client, on_outgoing_exit }
|
147
|
+
@outgoing_thread.name = "rookout-outgoing-thread"
|
138
148
|
|
139
149
|
message_handler = proc do |raw_message|
|
140
150
|
envelope = Com::Rookout::Envelope.decode raw_message.pack("c*")
|
@@ -150,7 +160,8 @@ module Rookout
|
|
150
160
|
Logger.instance.debug "Incoming loop - socket disconnected"
|
151
161
|
|
152
162
|
@pending_messages.push ExitMessage.new(send_thread)
|
153
|
-
|
163
|
+
@outgoing_thread.join
|
164
|
+
@outgoing_thread = nil
|
154
165
|
end
|
155
166
|
|
156
167
|
def outgoing client, on_exit
|
data/lib/rookout/exceptions.rb
CHANGED
@@ -105,7 +105,7 @@ module Rookout
|
|
105
105
|
end
|
106
106
|
|
107
107
|
class RookInvalidToken < ToolException
|
108
|
-
def initialize token
|
108
|
+
def initialize token = ""
|
109
109
|
super "The Rookout token supplied #{token[0..6]} is not valid; please check the token and try again",
|
110
110
|
{ token: token[0...6] }
|
111
111
|
end
|
data/lib/rookout/interface.rb
CHANGED
@@ -9,6 +9,7 @@ module Rookout
|
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@rook = nil
|
12
|
+
@start_options = nil
|
12
13
|
end
|
13
14
|
|
14
15
|
def start options = {}
|
@@ -19,14 +20,20 @@ module Rookout
|
|
19
20
|
begin
|
20
21
|
require_relative "rookout_singleton"
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
# If we are running post fork, use previous start_options
|
24
|
+
if options[:post_fork]
|
25
|
+
# Don't re-enable the fork handler
|
26
|
+
@start_options[:fork] = false
|
27
|
+
else
|
28
|
+
configure_logging options
|
29
|
+
configure_git options
|
24
30
|
|
25
|
-
|
26
|
-
|
31
|
+
@start_options = configure_start_options options
|
32
|
+
print_config @start_options
|
33
|
+
end
|
27
34
|
|
28
35
|
rook = RookoutSingleton.instance
|
29
|
-
rook.connect(
|
36
|
+
rook.connect(**@start_options)
|
30
37
|
rescue RookMissingToken, RookInvalidToken, RookInvalidOptions, RookVersionNotSupported => e
|
31
38
|
raise if throw_errors
|
32
39
|
STDERR.puts "[Rookout] Failed to start Rookout: #{e.message}"
|
@@ -12,6 +12,7 @@ module Rookout
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def read_attribute name
|
15
|
+
return RubyObjectNamespace.new @binding.receiver if name == "self"
|
15
16
|
raise Exceptions::RookAttributeNotFound, name unless @binding.local_variable_defined? name
|
16
17
|
RubyObjectNamespace.new @binding.local_variable_get name
|
17
18
|
end
|
@@ -40,9 +40,14 @@ module Rookout
|
|
40
40
|
@services_started = false
|
41
41
|
end
|
42
42
|
|
43
|
-
def connect token: nil, host: nil, port: nil, proxy: nil, labels: [], async_start: false,
|
43
|
+
def connect token: nil, host: nil, port: nil, proxy: nil, labels: [], async_start: false, fork: false
|
44
44
|
raise Exceptions::RookInterfaceException, "Multiple connection attempts not supported!" unless @agent_com.nil?
|
45
45
|
|
46
|
+
if fork
|
47
|
+
require_relative "atfork"
|
48
|
+
Rookout::ForkManager.instance.activate!
|
49
|
+
end
|
50
|
+
|
46
51
|
start_trigger_services
|
47
52
|
|
48
53
|
Logger.instance.debug "Initiating AgentCom-\t#{host}:#{port}"
|
@@ -61,6 +66,16 @@ module Rookout
|
|
61
66
|
@output.flush_messages if !@output.nil && !@agent_com.nil?
|
62
67
|
end
|
63
68
|
|
69
|
+
def post_fork_clean
|
70
|
+
@agent_com.stop
|
71
|
+
@agent_com = nil
|
72
|
+
|
73
|
+
@command_handler = nil
|
74
|
+
|
75
|
+
# We don't disable services because we will lose all loaded scripts
|
76
|
+
@services.clear_augs
|
77
|
+
end
|
78
|
+
|
64
79
|
attr_reader :services
|
65
80
|
|
66
81
|
private
|
@@ -18,14 +18,14 @@ module Rookout
|
|
18
18
|
def initialize tracer
|
19
19
|
@tracer = tracer
|
20
20
|
@augs = {}
|
21
|
-
@iseqs =
|
21
|
+
@iseqs = []
|
22
22
|
@trace_point = TracePoint.new :script_compiled do |tp|
|
23
23
|
begin
|
24
24
|
begin
|
25
25
|
iseq = tp.instruction_sequence
|
26
26
|
# Ignore script without sources
|
27
27
|
if iseq.absolute_path
|
28
|
-
@iseqs
|
28
|
+
@iseqs << iseq
|
29
29
|
evaluate_script iseq
|
30
30
|
end
|
31
31
|
rescue Exception => e
|
@@ -83,7 +83,7 @@ module Rookout
|
|
83
83
|
|
84
84
|
def evaluate_all_scripts_to_location location
|
85
85
|
positions = []
|
86
|
-
@iseqs.
|
86
|
+
@iseqs.each do |iseq|
|
87
87
|
position = evaluate_script_to_location iseq, iseq.absolute_path, location
|
88
88
|
next if position.nil?
|
89
89
|
|
data/lib/rookout/version.rb
CHANGED
data/rookout.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require_relative "lib/rookout/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "rookout"
|
6
|
+
spec.version = Rookout::VERSION
|
7
|
+
|
8
|
+
spec.authors = ["Liran Haimovitch"]
|
9
|
+
spec.email = ["support@rookout.com"]
|
10
|
+
spec.description = "rookout is the Ruby SDK for the Rookout Debugging Platform"
|
11
|
+
spec.summary = "rookout is the Ruby SDK for the Rookout Debugging Platform"
|
12
|
+
spec.homepage = "https://rookout.com"
|
13
|
+
spec.license = "Proprietary"
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
|
17
|
+
spec.files = `git ls-files -- ext/* lib/* bin/*`.split("\n") +
|
18
|
+
["lib/rookout/commit.rb", "LICENSE", "Rakefile", "rookout.gemspec"]
|
19
|
+
spec.extensions = ["ext/mkrf_conf.rb"]
|
20
|
+
spec.executables = ["rookout"]
|
21
|
+
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.required_ruby_version = ">= 2.6"
|
25
|
+
|
26
|
+
spec.add_dependency "binding_of_caller", ">= 0.7"
|
27
|
+
spec.add_dependency "concurrent-ruby", ">= 1.1"
|
28
|
+
spec.add_dependency "websocket-driver", ">= 0.5.0"
|
29
|
+
spec.add_dependency "event_emitter", ">= 0.2.6"
|
30
|
+
|
31
|
+
spec.add_development_dependency "google-protobuf", ">= 3.0.0"
|
32
|
+
spec.add_development_dependency "google-style", ">= 1.24.0"
|
33
|
+
spec.add_development_dependency "minitest", ">= 5.14"
|
34
|
+
spec.add_development_dependency "minitest-autotest", ">= 1.0"
|
35
|
+
spec.add_development_dependency "minitest-focus", ">= 1.1"
|
36
|
+
spec.add_development_dependency "minitest-rg", ">= 5.2"
|
37
|
+
spec.add_development_dependency "autotest-suffix", ">= 1.1"
|
38
|
+
spec.add_development_dependency "rake-compiler", ">= 1.0"
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rookout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liran Haimovitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -53,33 +53,33 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: event_emitter
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.2.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.2.6
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: google-protobuf
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
76
|
-
type: :
|
75
|
+
version: 3.0.0
|
76
|
+
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 3.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: google-style
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,12 +183,16 @@ email:
|
|
183
183
|
- support@rookout.com
|
184
184
|
executables:
|
185
185
|
- rookout
|
186
|
-
extensions:
|
186
|
+
extensions:
|
187
|
+
- ext/mkrf_conf.rb
|
187
188
|
extra_rdoc_files: []
|
188
189
|
files:
|
189
190
|
- LICENSE
|
191
|
+
- Rakefile
|
190
192
|
- bin/rookout
|
193
|
+
- ext/mkrf_conf.rb
|
191
194
|
- lib/rookout.rb
|
195
|
+
- lib/rookout/atfork.rb
|
192
196
|
- lib/rookout/augs/actions/action.rb
|
193
197
|
- lib/rookout/augs/actions/action_run_processor.rb
|
194
198
|
- lib/rookout/augs/aug.rb
|
@@ -247,6 +251,7 @@ files:
|
|
247
251
|
- lib/rookout/user_warnings.rb
|
248
252
|
- lib/rookout/utils.rb
|
249
253
|
- lib/rookout/version.rb
|
254
|
+
- rookout.gemspec
|
250
255
|
homepage: https://rookout.com
|
251
256
|
licenses:
|
252
257
|
- Proprietary
|