diff --git a/app.rb b/app.rb index b2f89ba..4380b6e 100644 --- a/app.rb +++ b/app.rb @@ -117,7 +117,6 @@ class TickTock def initialize @pid = ppid @procfs_f = format "/proc/%s/stat", @pid - puts @pid end def uptime @@ -185,20 +184,11 @@ class Sleep end def ppid - 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 + pid = ENV.fetch "PUMA_PID", Process.pid + begin + Integer pid + rescue ArgumentError + -1 end end diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000..8f35991 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1 @@ +ENV["PUMA_PID"] = Process.pid.to_s