Rackup 使用 Thin 代替 WEBrick
Sinatra 新手,刚刚启动并运行开发服务器,但 rackup
使用 WEBrick
而不是 Thin
,Thin
gem 是已经安装了,这必须是一个简单的配置调整,但我不知道在哪里。哦,当你在做的时候,当我更改源代码时,Thin
会自动刷新吗?当我更改源代码时,我似乎必须停止并重新启动WEBrick
。
编辑 正如所建议的,thin start
可以根据我的设置进行调整。它本身会抛出一个错误“start_tcp_server”:没有接受器(RuntimeError)
,这意味着我已经在该端口上运行了另一个服务。为了解决这个问题,我只需运行 thin start -p 9292
。希望这对其他人有帮助。
New to Sinatra, just development server up and running but rackup
is using WEBrick
instead of Thin
, Thin
gem is already installed, this has to be a simple configuration tweak but I don't know where. Oh while you are at it, does Thin
auto-refresh when I change the source code? It appears that I have to stop and restart WEBrick
when I make source code changes.
EDIT
As suggested, thin start
works with a tweak for my setup. By itself, it throws an error "start_tcp_server": no acceptor (RuntimeError)
which means I already have another service running on that port. To resolve the issue, I simply run thin start -p 9292
. Hope this helps someone else.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信您可能只想通过以下方式启动瘦:
bundle execrackup -s Thin
如果您使用的是 OSX,您可能想查看 Pow 用于您的开发环境。
对于在请求之间重新加载文件:如何让 Sinatra 在每次更改后自动重新加载文件?
I believe you'll likely just want to start up thin via something like:
bundle exec rackup -s thin
If you're on OSX you might want to check out Pow for your development environment.
For reloading files between requests: How to get Sinatra to auto-reload the file after each change?
您只需使用
$ Thin start
即可启动 Thin 服务器。如果您想要重新加载代码,请使用野外的几个重新加载库之一:Shotgun(它将派生并针对每个请求退出,在 Windows 上不起作用),机架重新加载器 (这是一个 Rack 中间件)或 Sinatra Reloader。我个人更喜欢 Sinatra Reloader,因为它只是重新加载已更改的文件,因此速度更快。此外,还可以添加应重新加载的其他文件和不得重新加载的文件。
You can start the server with Thin using just
$ thin start
.If you want code reloading, use one of the several reloading libraries in the wild: Shotgun (which will fork and exit for every request, does not work on Windows), Rack Reloader (which is a Rack middleware) or Sinatra Reloader. I personally favor Sinatra Reloader, since it just reloads files that have changed and is therefore faster. Also there's the possibility to add additional files which shall be reloaded and files that must not be reloaded.