开发者

Rackup to use Thin instead of WEBrick

开发者 https://www.devze.com 2023-04-11 15:05 出处:网络
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.

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 accep开发者_Go百科tor (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.


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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消