have Puma set the PID of the master process

This commit is contained in:
Ryan Cavicchioni 2025-04-03 20:47:42 -05:00
parent bb7f309b34
commit 8667d0571f
Signed by: ryanc
SSH Key Fingerprint: SHA256:KbXiwUnZnHFwFtt3Bytd+F3FN9pPHn1Z1cxMIE1TPbg
2 changed files with 6 additions and 15 deletions

20
app.rb
View File

@ -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

1
config/puma.rb Normal file
View File

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