2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-10 21:51:52 -05:00
|
|
|
require File.expand_path("../../../config/environment", __FILE__)
|
|
|
|
|
|
|
|
puts "Parent is now loaded"
|
|
|
|
|
2019-10-02 00:54:08 -04:00
|
|
|
class ForkExecDemon < Demon::Base
|
2018-01-10 21:51:52 -05:00
|
|
|
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
|