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

View File

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