How do I run my modular Sinatra app?
I'm building a new version of Lovers with Sinatra. You can view the Lovers source code on GitHub.
I'm able to successfully run my app in cucumber mode by running cucumber
via the CLI from the root directory of the repository. But...
1) how do I run the app in development mode?
It's a little tricky because it's a modular app, and I've moved the app.rb
file to lib/lovers/application开发者_如何学Python.rb
.
2) How do I run it with shotgun
so that it automatically restarts the app on every HTTP request?
3) When you run ruby app.rb
for a Sinatra app, what does that actually do?
If you answer part 3) well, I think I'll be able to figure out the answer to 1 & 2.
Thanks!
1) Just run bundle exec shotgun
from the project root. Shotgun, as opposed to other rack servers like thin, is specifically designed... actually... only designed for "development" mode... in that it reloads your code if it changes.
2) Why on every request? Shotgun automatically reloads as needed.
3) ruby app.rb
runs a small app server (as seen here: http://www.sinatrarb.com/) but is probably not what you want. Shotgun should do the trick.
The important thing to see here is config.ru
in loversapp's root directory. That's what shotgun and other rack servers are looking for. It loads your lib/lovers/application.rb
, sets the correct RACK_ENV
, and calls run Lovers::Application
.
精彩评论