Compare commits
2 Commits
bb7f309b34
...
7831c5da16
Author | SHA1 | Date | |
---|---|---|---|
7831c5da16 | |||
8667d0571f |
22
app.rb
22
app.rb
@ -117,7 +117,6 @@ class TickTock
|
|||||||
def initialize
|
def initialize
|
||||||
@pid = ppid
|
@pid = ppid
|
||||||
@procfs_f = format "/proc/%s/stat", @pid
|
@procfs_f = format "/proc/%s/stat", @pid
|
||||||
puts @pid
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def uptime
|
def uptime
|
||||||
@ -185,20 +184,11 @@ class Sleep
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ppid
|
def ppid
|
||||||
pid = Process.pid
|
pid = ENV.fetch "PUMA_PID", Process.pid
|
||||||
# self
|
begin
|
||||||
ps = File.open "/proc/#{pid}/stat", &:readline
|
Integer pid
|
||||||
ps = ps.split(" ")
|
rescue ArgumentError
|
||||||
ppid = Integer(ps[3])
|
-1
|
||||||
|
|
||||||
# ppid
|
|
||||||
ps = File.open "/proc/#{ppid}/stat", &:readline
|
|
||||||
ps = ps.split(" ")
|
|
||||||
|
|
||||||
if ps[1].include? "ruby"
|
|
||||||
ppid
|
|
||||||
else
|
|
||||||
pid
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -384,7 +374,7 @@ post "/halt" do
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/pid" do
|
get "/pid", provides: "json" do
|
||||||
pretty = params.key? :pretty
|
pretty = params.key? :pretty
|
||||||
|
|
||||||
jsonify({ppid: ppid, pid: Process.pid}, pretty:)
|
jsonify({ppid: ppid, pid: Process.pid}, pretty:)
|
||||||
|
1
config/puma.rb
Normal file
1
config/puma.rb
Normal file
@ -0,0 +1 @@
|
|||||||
|
ENV["PUMA_PID"] = Process.pid.to_s
|
Loading…
x
Reference in New Issue
Block a user