Compare commits

..

No commits in common. "7831c5da160cdc4e94e70ce08bf2574672af4498" and "bb7f309b34559fb3eee565b354e5e6cad395c549" have entirely different histories.

2 changed files with 16 additions and 7 deletions

22
app.rb
View File

@ -117,6 +117,7 @@ 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
@ -184,11 +185,20 @@ class Sleep
end end
def ppid def ppid
pid = ENV.fetch "PUMA_PID", Process.pid pid = Process.pid
begin # self
Integer pid ps = File.open "/proc/#{pid}/stat", &:readline
rescue ArgumentError ps = ps.split(" ")
-1 ppid = Integer(ps[3])
# ppid
ps = File.open "/proc/#{ppid}/stat", &:readline
ps = ps.split(" ")
if ps[1].include? "ruby"
ppid
else
pid
end end
end end
@ -374,7 +384,7 @@ post "/halt" do
nil nil
end end
get "/pid", provides: "json" do get "/pid" do
pretty = params.key? :pretty pretty = params.key? :pretty
jsonify({ppid: ppid, pid: Process.pid}, pretty:) jsonify({ppid: ppid, pid: Process.pid}, pretty:)

View File

@ -1 +0,0 @@
ENV["PUMA_PID"] = Process.pid.to_s