Rackup to use Thin instead of WEBrick
Asked Answered
J

2

12

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.

Jadejaded answered 5/10, 2011 at 21:50 Comment(0)
L
12

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.

Lacagnia answered 6/10, 2011 at 8:29 Comment(2)
Thanks, thin start works for me with a small tweak, see updated question for answer.Jadejaded
Sinatra Reloader is much faster than Shotgun. Thanks!Gametophore
H
15

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?

Hammerlock answered 5/10, 2011 at 22:17 Comment(0)
L
12

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.

Lacagnia answered 6/10, 2011 at 8:29 Comment(2)
Thanks, thin start works for me with a small tweak, see updated question for answer.Jadejaded
Sinatra Reloader is much faster than Shotgun. Thanks!Gametophore

© 2022 - 2024 — McMap. All rights reserved.