discourse/script/demon_test/parent.rb
Krzysztof Kotlarek 35b1185a08 FIX: Revert Demon::DemonBase back to Demon::Base (#8132)
I introduced DemonBase because I had got some conflict between `demon/base.rb` and `jobs/base.rb`, however, to not rename base class, it is possible to use regex on absolute path in Zeitwerk custom inflector.
2019-10-02 14:54:08 +10:00

28 lines
421 B
Ruby

# frozen_string_literal: true
require File.expand_path("../../../config/environment", __FILE__)
puts "Parent is now loaded"
class ForkExecDemon < Demon::Base
def self.prefix
"fork-exec-child"
end
def run
if @pid = fork
write_pid_file
return
end
exec "./child #{parent_pid}"
end
end
ForkExecDemon.start(1, verbose: true)
while true
ForkExecDemon.ensure_running
sleep 0.1
end