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

前端 未结 6 563
滥情空心
滥情空心 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:42

    You can call Rails::Server.new.options[:Port] to get the port that your Rails server is running on. This will parse the -p 3001 args from your rails server command, or default to port 3000.

提交回复
热议问题