Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # request.port is unfortunately useless from within the app, as it
- # does not reflect the backend bind port, but the frontend proxy.
- # So we have to reverse lookup the PID to figure out our port.
- def backend_server_port
- Thread.current[:backend_server_port] ||= begin
- logger.debug "Attempting to reverse-lookup server port from PID file"
- port = nil
- Dir["#{RAILS_ROOT}/tmp/pids/thin.*.pid"].each do |f|
- pid = File.read(f).chomp.to_i
- if pid == $$
- port = f.gsub(/.*\.([0-9]+)\.pid$/, '\1').to_i
- raise "Malformed PID file does not contain port: #{f}" if port == 0
- break
- end
- end
- port || 3000 # guess 3000 for local dev
- end
- end
Add Comment
Please, Sign In to add comment