Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rackup to use Thin instead of WEBrick

Tags:

sinatra

thin

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.

like image 663
Johnny Klassy Avatar asked Oct 05 '11 21:10

Johnny Klassy


2 Answers

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?

like image 187
jodell Avatar answered Jan 19 '23 00:01

jodell


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.

like image 22
tbuehlmann Avatar answered Jan 18 '23 22:01

tbuehlmann