gc_hacks 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gc_hacks/railtie.rb +9 -0
- data/lib/gc_hacks/version.rb +1 -1
- data/lib/gc_hacks.rb +15 -9
- metadata +5 -4
data/lib/gc_hacks/version.rb
CHANGED
data/lib/gc_hacks.rb
CHANGED
@@ -17,8 +17,8 @@ module GCHacks
|
|
17
17
|
|
18
18
|
def root
|
19
19
|
@root ||=
|
20
|
-
if defined?(Rails)
|
21
|
-
Rails.root.to_s
|
20
|
+
if defined?(Rails) && Rails.respond_to?(:application)
|
21
|
+
Rails.application.root.to_s
|
22
22
|
elsif defined?(RAILS_ROOT)
|
23
23
|
RAILS_ROOT
|
24
24
|
else
|
@@ -47,32 +47,35 @@ module GCHacks
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def send_command(cmd, pid)
|
50
|
-
File.open(
|
50
|
+
File.open(cmd_file, "w"){|f| f.puts cmd}
|
51
51
|
Process.kill("WINCH", pid)
|
52
52
|
end
|
53
53
|
|
54
54
|
def check_and_run_commands
|
55
|
-
read_command_file.
|
56
|
-
|
55
|
+
read_command_file.each_line do |cmd|
|
56
|
+
# puts "received cmd #{cmd}"
|
57
|
+
case c = cmd.chomp
|
57
58
|
when 'HEAPDUMP' then heap_dump
|
58
59
|
when 'STARTTRACE' then start_trace
|
59
60
|
when 'STOPTRACE' then stop_trace
|
60
61
|
else
|
61
|
-
logger.info "unknown gc command: '#{
|
62
|
+
logger.info "unknown gc command: '#{c}'"
|
62
63
|
end
|
63
64
|
end
|
64
65
|
ensure
|
65
66
|
remove_command_file
|
66
67
|
end
|
67
68
|
|
68
|
-
|
69
|
+
def cmd_file
|
70
|
+
"#{tmp_dir}/gc_command.txt"
|
71
|
+
end
|
69
72
|
|
70
73
|
def read_command_file
|
71
|
-
File.exist?(
|
74
|
+
File.exist?(cmd_file) ? File.read(cmd_file) : ""
|
72
75
|
end
|
73
76
|
|
74
77
|
def remove_command_file
|
75
|
-
File.exist?(
|
78
|
+
File.exist?(cmd_file) && File.unlink(cmd_file)
|
76
79
|
end
|
77
80
|
|
78
81
|
def can_trace?
|
@@ -135,3 +138,6 @@ module GCHacks
|
|
135
138
|
end
|
136
139
|
|
137
140
|
end
|
141
|
+
|
142
|
+
require 'gc_hacks/railtie' if defined?(Rails) && Rails::VERSION::STRING > "3.0"
|
143
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gc_hacks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stefan Kaes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-25 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- gc_hacks.gemspec
|
43
43
|
- init.rb
|
44
44
|
- lib/gc_hacks.rb
|
45
|
+
- lib/gc_hacks/railtie.rb
|
45
46
|
- lib/gc_hacks/version.rb
|
46
47
|
- rails/init.rb
|
47
48
|
has_rdoc: true
|