How to find the local port a rails instance is running on?

前端 未结 6 568
滥情空心
滥情空心 2020-11-30 12:23

So I would like my Rails app instances to register themselves on a \"I\'m up\" kind of thing I\'m playing with, and I\'d like it to be able to mention what local port it\'s

6条回答
  •  被撕碎了的回忆
    2020-11-30 12:52

    From inside any controller action, check the content of request.port, thus:

    class SomeController < ApplicationController
      def some_action
        raise "I'm running on port #{request.port}."
      end
    end
    

提交回复
热议问题