mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 11:33:06 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
33 lines
564 B
Ruby
Executable File
33 lines
564 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
$parent_pid = ARGV[0].to_i
|
|
|
|
puts "Hello from #{Process.pid} my parent is #{$parent_pid}"
|
|
|
|
Thread.new do
|
|
|
|
def alive?(pid)
|
|
Process.kill(0, pid)
|
|
true
|
|
rescue
|
|
false
|
|
end
|
|
|
|
while true
|
|
begin
|
|
unless alive?($parent_pid)
|
|
STDERR.puts "Parent was terminated!"
|
|
Process.kill "TERM", Process.pid
|
|
sleep 10
|
|
Process.kill "KILL", Process.pid
|
|
end
|
|
rescue => e
|
|
STDERR.puts "URGENT monitoring thread had an exception #{e}"
|
|
end
|
|
sleep 1
|
|
end
|
|
end
|
|
|
|
sleep
|