Sinatra 以编程方式获取端口和有关服务的其他信息
我有一个 sinatra 服务 foo.rb
要在不同的端口上运行它,我会输入“ruby foo.rb -p 5000”。
当程序运行时,我希望能够获取端口(在本例中为 5000)和其他信息。有没有办法在应用程序运行时获取这样的信息?
谢谢
I have a sinatra service foo.rb
To run it I on a different port I would type "ruby foo.rb -p 5000".
While the program is running I would like to be able to get the port (in this case 5000) and other information. Is there a way to get info like this while the app is running?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够在任何 Sinatra 操作中使用
settings.port
访问它。有关所有内置设置的列表,请参阅此页面。
You should be able to get to it with
settings.port
in any Sinatra action.See this page for a list of all the built-in settings.