If we don't deamonize the Rails server we have far more direct control over the process.
Open3.popen2e(
'rails',
'server',
'--environment', rails_environment,
'--binding', rails_hostname,
'--port', rails_port.to_s,
chdir: app_root
) do |stdin, output, thread|
stdin.close
# Do things and then quit the server.
Process.kill('TERM', thread.pid)
# After the process stopped we can read the entire server output. This is
# useful when debugging broken runs and possibly digging performance
# information out of the request logs.
logger.debug(output.read)
end
If we don't deamonize the Rails server we have far more direct control over the process.